├── .gitignore ├── .kateconfig ├── CMakeLists.txt ├── Changes.md ├── LICENSE ├── README.md ├── cmake └── modules │ ├── AddBoostTests.cmake │ ├── AddCompileTests.cmake │ ├── AddOpenTarget.cmake │ ├── AddPackage.cmake │ ├── CPackCommonPackageOptions.cmake.in │ ├── CPackPackageConfig.cmake.in │ ├── DefineSkeletonGenerationTargetsIfPossible.cmake │ ├── Doxyfile.in │ ├── DoxygenDefaults.cmake │ ├── FindLibClang.cmake │ ├── GenerateDoxygenDocumentation.cmake │ ├── GetDistribInfo.cmake │ ├── GetKeyValueFromShellLikeConfig.cmake │ ├── GuessBuildType.cmake │ ├── PreparePCHHeader.cmake.in │ ├── TeamCityIntegration.cmake │ ├── TestCMakeLists.txt.in │ ├── UseCompilerOption.cmake │ ├── UsePCHFile.cmake │ ├── class.tpl.in │ ├── class_tester.tpl.in │ ├── compile_test.cmake.in │ ├── libclang_get_version.cpp │ ├── new_class_tester_post.cmake.in │ ├── pch_template.h.in │ ├── render_template.cmake.in │ └── unit_tests_main_skeleton.cc.in ├── contrib └── sample.sanitizer-rules ├── src ├── CMakeLists.txt ├── choose_from_list_dialog.cpp ├── choose_from_list_dialog.h ├── clang │ ├── compiler_options.cpp │ ├── compiler_options.h │ ├── debug.h │ ├── diagnostic_message.h │ ├── disposable.h │ ├── kind_of.h │ ├── location.cpp │ ├── location.h │ ├── to_string.cpp │ ├── to_string.h │ ├── unsaved_files_list.cpp │ └── unsaved_files_list.h ├── clang_code_completion_item.cpp ├── clang_code_completion_item.h ├── clang_code_completion_model.cpp ├── clang_code_completion_model.h ├── clang_completion_settings.ui ├── clang_settings.ui ├── config.h.in ├── cpp_helper_plugin.cpp ├── cpp_helper_plugin.h ├── cpp_helper_plugin_config_page.cpp ├── cpp_helper_plugin_config_page.h ├── cpp_helper_plugin_view.cpp ├── cpp_helper_plugin_view.h ├── cpp_helper_plugin_view_document_services.cpp ├── cpp_helper_plugin_view_explorer.cpp ├── cpp_helper_plugin_view_search_services.cpp ├── data │ └── qt4.incset.in ├── database_manager.cpp ├── database_manager.h ├── database_options.kcfgc ├── detect_compiler_paths.ui ├── diagnostic_messages_model.cpp ├── diagnostic_messages_model.h ├── document_info.cpp ├── document_info.h ├── document_proxy.cpp ├── document_proxy.h ├── header_files_cache.h ├── include_helper_completion_model.cpp ├── include_helper_completion_model.h ├── index │ ├── combined_index.cpp │ ├── combined_index.h │ ├── database.cpp │ ├── database.h │ ├── details │ │ ├── container_info.h │ │ ├── database.h │ │ ├── worker.cpp │ │ └── worker.h │ ├── document.h │ ├── document_extras.cpp │ ├── document_extras.h │ ├── indexer.cpp │ ├── indexer.h │ ├── kind.cpp │ ├── kind.h │ ├── numeric_value_range_processor.cpp │ ├── numeric_value_range_processor.h │ ├── search_result.cpp │ ├── search_result.h │ ├── serialize.h │ ├── types.h │ ├── utils.cpp │ └── utils.h ├── indexing_targets_list_model.cpp ├── indexing_targets_list_model.h ├── indices_table_model.cpp ├── indices_table_model.h ├── katecpphelperplugin.desktop.in ├── katecpphelperplugin_database_options.kcfg ├── other_settings.ui ├── path_config.ui ├── plugin_configuration.cpp ├── plugin_configuration.h ├── plugin_tool_view.ui ├── preprocessor_completion_model.cpp ├── preprocessor_completion_model.h ├── sample.sanitizer-rules ├── sanitize_snippet.cpp ├── sanitize_snippet.h ├── search_results_table_model.cpp ├── search_results_table_model.h ├── session_paths_sets.ui ├── string_cast.h ├── test │ ├── CMakeLists.txt │ ├── config.h.in │ ├── data │ │ ├── classes │ │ │ ├── test_001.cc │ │ │ ├── test_002.cc │ │ │ ├── test_003.cc │ │ │ ├── test_004.cc │ │ │ ├── test_005.cc │ │ │ ├── test_006.cc │ │ │ ├── test_007.cc │ │ │ ├── test_008.cc │ │ │ └── test_009.cc │ │ ├── functions │ │ │ ├── test_001.cc │ │ │ ├── test_002.cc │ │ │ ├── test_003.cc │ │ │ ├── test_004.cc │ │ │ ├── test_005.cc │ │ │ └── test_006.cc │ │ ├── test_manifest.in │ │ ├── typedefs │ │ │ ├── test_001.cc │ │ │ ├── test_002.cc │ │ │ └── test_003.cc │ │ └── variables │ │ │ ├── test_001.cc │ │ │ ├── test_002.cc │ │ │ ├── test_003.cc │ │ │ ├── test_004.cc │ │ │ ├── test_005.cc │ │ │ ├── test_006.cc │ │ │ ├── test_007.cc │ │ │ ├── test_008.cc │ │ │ ├── test_009.cc │ │ │ ├── test_010.cc │ │ │ ├── test_011.cc │ │ │ ├── test_012.cc │ │ │ ├── test_013.cc │ │ │ ├── test_014.cc │ │ │ ├── test_015.cc │ │ │ ├── test_016.cc │ │ │ ├── test_017.cc │ │ │ ├── test_018.cc │ │ │ ├── test_019.cc │ │ │ ├── test_020.cc │ │ │ └── test_021.cc │ ├── database_manager_tester.cpp │ ├── header_files_cache_tester.cpp │ ├── index_utils_tester.cpp │ ├── indexer_tester.cpp │ ├── indexer_tester.h │ ├── indexing_test.cpp │ ├── sanitize_snippet_tester.cpp │ ├── serialize_tester.cpp │ ├── translation_unit_tester.cpp │ ├── unsaved_files_list_tester.cpp │ └── utils_tester.cpp ├── translation_unit.cpp ├── translation_unit.h ├── ui.rc ├── utils.cpp └── utils.h └── third_party └── kde4-kate-interfaces ├── 4.10 ├── kate │ ├── application.h │ ├── documentmanager.h │ ├── mainwindow.h │ ├── plugin.h │ ├── pluginconfigpageinterface.h │ └── pluginmanager.h └── kate_export.h ├── 4.8 ├── kate │ ├── application.h │ ├── documentmanager.h │ ├── mainwindow.h │ ├── plugin.h │ ├── pluginconfigpageinterface.h │ └── pluginmanager.h └── kate_export.h ├── 4.9 ├── kate │ ├── application.h │ ├── documentmanager.h │ ├── mainwindow.h │ ├── plugin.h │ ├── pluginconfigpageinterface.h │ └── pluginmanager.h └── kate_export.h └── latest /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | .swp.* 3 | *.kate-swp 4 | -------------------------------------------------------------------------------- /.kateconfig: -------------------------------------------------------------------------------- 1 | kate: space-indent on; 2 | kate: tab-width 4; 3 | kate: indent-width 4; 4 | kate: replace-tabs on; 5 | 6 | kate-wildcard(*.h;*.cpp;*.moc): mode C++/Qt4; 7 | kate-wildcard(*.h;*.cpp;*.moc): hl C++/Qt4; 8 | -------------------------------------------------------------------------------- /cmake/modules/AddOpenTarget.cmake: -------------------------------------------------------------------------------- 1 | # - Define a target to open a file/URI in the user's preferred application 2 | # 3 | # It uses `xdg-open` for Linux platform to open HTML docs or PDF documents... 4 | # or anything else that possible to open w/ that tool. 5 | # 6 | # Usage: 7 | # add_open_target( 8 | # target-name 9 | # file-path 10 | # [DEPENDS dep1 ... depN] 11 | # [COMMENT text] 12 | # ) 13 | # 14 | # Open a file (or URI) given as `file-path` using target named `target-name`. 15 | # Dependencies actually can be files and/or other targets. 16 | # Example: 17 | # 18 | # add_open_target( 19 | # show-api-docs 20 | # ${CMAKE_BINARY_DIR}/docs/html/index.html 21 | # DEPENDS doxygen 22 | # COMMENT "Show API documentation" 23 | # ) 24 | # 25 | # Will open given `index.html` in a default browser. For Makefiles generator 26 | # it runs w/ `make show-api-docs` command. Also it depends on another target 27 | # named `doxygen` 28 | # 29 | 30 | #============================================================================= 31 | # Copyright 2014 by Alex Turbov 32 | # 33 | # Distributed under the OSI-approved BSD License (the "License"); 34 | # see accompanying file LICENSE for details. 35 | # 36 | # This software is distributed WITHOUT ANY WARRANTY; without even the 37 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 38 | # See the License for more information. 39 | #============================================================================= 40 | # (To distribute this file outside of this repository, substitute the full 41 | # License text for the above reference.) 42 | 43 | include(CMakeParseArguments) 44 | 45 | if(NOT WIN32 AND NOT XDG_OPEN_EXECUTABLE) 46 | find_program( 47 | XDG_OPEN_EXECUTABLE 48 | NAMES xdg-open 49 | DOC "opens a file or URL in the user's preferred application" 50 | ) 51 | if(XDG_OPEN_EXECUTABLE) 52 | message(STATUS "Found xdg-open: ${XDG_OPEN_EXECUTABLE}") 53 | endif() 54 | endif() 55 | 56 | function(add_open_target target file) 57 | if(NOT XDG_OPEN_EXECUTABLE) 58 | return() 59 | endif() 60 | 61 | set(_options) 62 | set(_one_value_args COMMENT) 63 | set(_multi_value_args DEPENDS) 64 | cmake_parse_arguments(add_open_target "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN}) 65 | 66 | if(NOT add_open_target_COMMENT) 67 | set(add_open_target_COMMENT "Opening ${file}...") 68 | endif() 69 | 70 | # Form lists of target and file dependencies 71 | set(_dep_targets) 72 | set(_dep_files) 73 | foreach(_d ${add_open_target_DEPENDS}) 74 | # Check if current dependency is a target 75 | if(TARGET ${_d}) 76 | if(_dep_targets) 77 | set(_dep_targets "${_dep_targets} ${_d}") 78 | else() 79 | set(_dep_targets "${_d}") 80 | endif() 81 | else() 82 | if(_dep_files) 83 | set(_dep_files "${_dep_files} ${_d}") 84 | else() 85 | set(_dep_files "${_d}") 86 | endif() 87 | endif() 88 | endforeach() 89 | 90 | if(_dep_files) 91 | add_custom_target( 92 | ${target} 93 | COMMAND ${XDG_OPEN_EXECUTABLE} ${file} 94 | DEPENDS ${_dep_files} 95 | COMMENT ${add_open_target_COMMENT} 96 | VERBATIM 97 | ) 98 | else() 99 | add_custom_target( 100 | ${target} 101 | COMMAND ${XDG_OPEN_EXECUTABLE} ${file} 102 | COMMENT ${add_open_target_COMMENT} 103 | VERBATIM 104 | ) 105 | endif() 106 | 107 | if(_dep_targets) 108 | add_dependencies(${target} ${_dep_targets}) 109 | endif() 110 | endfunction() 111 | 112 | # X-Chewy-RepoBase: https://raw.githubusercontent.com/mutanabbi/chewy-cmake-rep/master/ 113 | # X-Chewy-Path: AddOpenTarget.cmake 114 | # X-Chewy-Version: 1.2 115 | # X-Chewy-Description: Define a target to open a file/URI in the user's preferred application 116 | -------------------------------------------------------------------------------- /cmake/modules/CPackCommonPackageOptions.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2013-2014 by Alex Turbov 3 | # 4 | # Options common to all generated packages 5 | # 6 | # NOTE This file included from few places 7 | # 0) add_package() function 8 | # 1) and from particular CPack's package config file 9 | # 10 | 11 | set(CPACK_PROJECT_VERSION "@set_common_package_options_PROJECT_VERSION@") 12 | 13 | set(CPACK_PACKAGE_VENDOR "@set_common_package_options_VENDOR_NAME@") 14 | set(CPACK_PACKAGE_CONTACT "@set_common_package_options_VENDOR_CONTACT@") 15 | set(CPACK_PACKAGE_SIGNER "@set_common_package_options_SIGN_BY@") 16 | set(CPACK_PACKAGE_SIGN_KEY_ID "@set_common_package_options_SIGN_WITH@") 17 | 18 | set(CPACK_RESOURCE_FILE_LICENSE "@set_common_package_options_LICENSE_FILE@") 19 | set(CPACK_RESOURCE_FILE_README "@set_common_package_options_README_FILE@") 20 | set(CPACK_PACKAGE_DESCRIPTION_FILE "@set_common_package_options_README_FILE@") 21 | 22 | set(CPACK_INSTALL_PREFIX "@set_common_package_options_PACKAGE_INSTALL_PREFIX@") 23 | 24 | set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "@set_common_package_options_HOMEPAGE@") 25 | set(CPACK_RPM_PACKAGE_URL "@set_common_package_options_HOMEPAGE@") 26 | 27 | set(CPACK_ALL_PACKAGES_TARGET_NAME "@set_common_package_options_ALL_PACKAGES_TARGET_NAME@") 28 | 29 | # kate: hl cmake; 30 | -------------------------------------------------------------------------------- /cmake/modules/CPackPackageConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright 2012-2013 by Alex Turbov 3 | # 4 | 5 | # Obtain settings shared among all generated packages 6 | include(${CMAKE_BINARY_DIR}/CPackCommonPackageOptions.cmake) 7 | 8 | set(CPACK_GENERATOR ${CPACK_GENERATOR}) 9 | set(CPACK_SOURCE_GENERATOR ${CPACK_SOURCE_GENERATOR}) 10 | set(CPACK_CMAKE_GENERATOR "${CMAKE_GENERATOR}") 11 | 12 | set(CPACK_INSTALL_CMAKE_PROJECTS "${CMAKE_BINARY_DIR};${add_package_NAME};${add_package_NAME};/") 13 | 14 | set(CPACK_PACKAGE_NAME ${add_package_NAME}) 15 | set(CPACK_PACKAGE_VERSION ${add_package_VERSION}) 16 | set(CPACK_PACKAGE_DESCRIPTION "${add_package_DESCRIPTION}") 17 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${add_package_SUMMARY}") 18 | set(CPACK_SET_DESTDIR "ON") 19 | 20 | # Debian specifics 21 | if(CPACK_GENERATOR STREQUAL "DEB") 22 | # Define package filename according Debian rules 23 | set( 24 | CPACK_PACKAGE_FILE_NAME 25 | "${add_package_NAME}_${add_package_VERSION}_${add_package_ARCHITECTURE}" 26 | ) 27 | set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${add_package_ARCHITECTURE}") 28 | set(CPACK_DEBIAN_PACKAGE_BREAKS "${add_package_BREAKS}") 29 | set(CPACK_DEBIAN_PACKAGE_CONFLICTS "${add_package_CONFLICTS}") 30 | set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${add_package_CONTROL_FILES}") 31 | set(CPACK_DEBIAN_PACKAGE_DEPENDS "${add_package_DEPENDS}") 32 | set(CPACK_DEBIAN_PACKAGE_ENHANCES "${add_package_ENHANCES}") 33 | set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "${add_package_HOMEPAGE}") 34 | set(CPACK_DEBIAN_PACKAGE_PREDEPENDS "${add_package_PRE_DEPENDS}") 35 | set(CPACK_DEBIAN_PACKAGE_PRIORITY "${add_package_PRIORITY}") 36 | set(CPACK_DEBIAN_PACKAGE_PROVIDES "${add_package_PROVIDES}") 37 | set(CPACK_DEBIAN_PACKAGE_RECOMMENDS "${add_package_RECOMMENDS}") 38 | set(CPACK_DEBIAN_PACKAGE_REPLACES "${add_package_REPLACES}") 39 | set(CPACK_DEBIAN_PACKAGE_SECTION "${add_package_SECTION}") 40 | set(CPACK_DEBIAN_PACKAGE_SUGGESTS "${add_package_SUGGESTS}") 41 | 42 | # RPM specifics 43 | elseif(CPACK_GENERATOR STREQUAL "RPM") 44 | # Define package filename according RHEL rules 45 | set( 46 | CPACK_PACKAGE_FILE_NAME 47 | "${add_package_NAME}-${add_package_VERSION}.${add_package_ARCHITECTURE}" 48 | ) 49 | set(CPACK_RPM_PACKAGE_ARCHITECTURE "${add_package_ARCHITECTURE}") 50 | set(CPACK_RPM_PACKAGE_CONFLICTS "${add_package_CONFLICTS}") 51 | set(CPACK_RPM_PACKAGE_REQUIRES "${add_package_DEPENDS}") 52 | set(CPACK_RPM_PACKAGE_SUGGESTS "${add_package_SUGGESTS}") 53 | set(CPACK_RPM_PACKAGE_PROVIDES "${add_package_PROVIDES}") 54 | set(CPACK_RPM_PACKAGE_OBSOLETES "${add_package_OBSOLETES}") 55 | set(CPACK_RPM_PACKAGE_GROUP "${add_package_SECTION}") 56 | set(CPACK_RPM_CHANGELOG_FILE "${add_package_CHANGELOG_FILE}") 57 | set(CPACK_RPM_PRE_INSTALL_SCRIPT_FILE "${add_package_PRE_INSTALL_SCRIPT_FILE}") 58 | set(CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE "${add_package_PRE_UNINSTALL_SCRIPT_FILE}") 59 | set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${add_package_POST_INSTALL_SCRIPT_FILE}") 60 | set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${add_package_POST_UNINSTALL_SCRIPT_FILE}") 61 | set(CPACK_RPM_USER_FILELIST "${add_package_USER_FILELIST}") 62 | set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "${add_package_EXCLUDE_FROM_AUTO_FILELIST}") 63 | 64 | endif() 65 | 66 | # kate: hl cmake; 67 | -------------------------------------------------------------------------------- /cmake/modules/FindLibClang.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Find clang C API library 3 | # 4 | # NOTE Use this module for LLVM/Clang < 4.x 5 | # 6 | 7 | #============================================================================= 8 | # Copyright 2012-2013 by Alex Turbov 9 | # 10 | # Distributed under the OSI-approved BSD License (the "License"); 11 | # see accompanying file LICENSE for details. 12 | # 13 | # This software is distributed WITHOUT ANY WARRANTY; without even the 14 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 | # See the License for more information. 16 | #============================================================================= 17 | # (To distribute this file outside of this repository, substitute the full 18 | # License text for the above reference.) 19 | 20 | 21 | include(FindPackageHandleStandardArgs) 22 | 23 | if(LibClang_FIND_VERSION_EXACT) 24 | if(LibClang_FIND_VERSION_MAJOR AND LibClang_FIND_VERSION_MINOR) 25 | set(_llvm_config_programs llvm-config-${LibClang_FIND_VERSION_MAJOR}.${LibClang_FIND_VERSION_MINOR}) 26 | else() 27 | message(FATAL_ERROR "EXACT version match requested, but no version specified!") 28 | endif() 29 | else() 30 | set(_llvm_config_programs 31 | llvm-config-3.8 32 | llvm-config-3.7 33 | llvm-config-3.6 34 | llvm-config-3.5 35 | llvm-config-3.4 36 | llvm-config-3.3 37 | ) 38 | endif() 39 | 40 | # Try to find it via `llvm-config` if no location specified 41 | # in a command line... 42 | if(NOT (LLVM_INCLUDEDIR OR LLVM_LIBDIR)) 43 | # Use `llvm-config` to locate libclang.so 44 | find_program( 45 | LLVM_CONFIG_EXECUTABLE 46 | NAMES ${_llvm_config_programs} llvm-config 47 | ) 48 | if(LLVM_CONFIG_EXECUTABLE) 49 | message(STATUS "Found LLVM configuration tool: ${LLVM_CONFIG_EXECUTABLE}") 50 | 51 | # Get LLVM library dir 52 | execute_process( 53 | COMMAND ${LLVM_CONFIG_EXECUTABLE} --libdir 54 | OUTPUT_VARIABLE LLVM_LIBDIR 55 | OUTPUT_STRIP_TRAILING_WHITESPACE 56 | ) 57 | execute_process( 58 | COMMAND ${LLVM_CONFIG_EXECUTABLE} --includedir 59 | OUTPUT_VARIABLE LLVM_INCLUDEDIR 60 | OUTPUT_STRIP_TRAILING_WHITESPACE 61 | ) 62 | endif() 63 | endif() 64 | 65 | # Try to find libclang.so 66 | # NOTE Try to find libclang even if `llvm-config` is not found! 67 | # User still can specify its location via overriding LLVM_LIBDIR and LLVM_INCLUDEDIR! 68 | find_library( 69 | LIBCLANG_LIBRARY 70 | clang 71 | PATH ${LLVM_LIBDIR} 72 | ) 73 | 74 | # Do version check only if library was actually found 75 | if(LIBCLANG_LIBRARY) 76 | # Try to compile sample test which would output clang version 77 | try_run( 78 | _clang_get_version_run_result 79 | _clang_get_version_compile_result 80 | ${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_LIST_DIR}/libclang_get_version.cpp 81 | CMAKE_FLAGS 82 | -DLINK_LIBRARIES:STRING=${LIBCLANG_LIBRARY} 83 | -DINCLUDE_DIRECTORIES:STRING=${LLVM_INCLUDEDIR} 84 | COMPILE_OUTPUT_VARIABLE _clang_get_version_compile_output 85 | RUN_OUTPUT_VARIABLE _clang_get_version_run_output 86 | ) 87 | # Extract clang version. In my system this string look like: 88 | # "clang version 3.1 (branches/release_31)" 89 | # In Ubuntu 12.10 it looks like: 90 | # "Ubuntu clang version 3.0-6ubuntu3 (tags/RELEASE_30/final) (based on LLVM 3.0)" 91 | string( 92 | REGEX 93 | REPLACE ".*clang version ([23][^ \\-]+)[ \\-].*" "\\1" 94 | LIBCLANG_VERSION 95 | "${_clang_get_version_run_output}" 96 | ) 97 | 98 | message(STATUS "Found Clang C API: ${LIBCLANG_LIBRARY} (version ${LIBCLANG_VERSION})") 99 | 100 | # TODO Add imported target 101 | endif() 102 | 103 | find_package_handle_standard_args( 104 | LibClang 105 | REQUIRED_VARS LIBCLANG_LIBRARY 106 | VERSION_VAR LIBCLANG_VERSION 107 | ) 108 | 109 | # X-Chewy-RepoBase: https://raw.githubusercontent.com/mutanabbi/chewy-cmake-rep/master/ 110 | # X-Chewy-Path: FindLibClang.cmake 111 | # X-Chewy-Version: 2.2 112 | # X-Chewy-Description: Find clang C API library 113 | # X-Chewy-AddonFile: libclang_get_version.cpp 114 | -------------------------------------------------------------------------------- /cmake/modules/GetKeyValueFromShellLikeConfig.cmake: -------------------------------------------------------------------------------- 1 | # - Getting value by a key from simple shell compatible 2 | # trivial config file 3 | # 4 | # Some data needed for build configuration may resides in a 5 | # simple form of `key=value` wich is widely used to store 6 | # configuration data for shell scripts. 7 | # 8 | # 9 | 10 | #============================================================================= 11 | # Copyright 2016 by Alex Turbov 12 | # 13 | # Distributed under the OSI-approved BSD License (the "License"); 14 | # see accompanying file LICENSE for details. 15 | # 16 | # This software is distributed WITHOUT ANY WARRANTY; without even the 17 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 18 | # See the License for more information. 19 | #============================================================================= 20 | # (To distribute this file outside of this repository, substitute the full 21 | # License text for the above reference.) 22 | 23 | 24 | function(get_value_from_config_file FILENAME) 25 | if(NOT UNIX) 26 | message(FATAL_ERROR "Sorry, not implemented for this OS yet") 27 | endif() 28 | 29 | if(FILENAME) 30 | set(_get_value_from_config_file_FILENAME "${FILENAME}") 31 | else() 32 | message(FATAL_ERROR "No filename has given in call to `get_value_from_config_file()`") 33 | endif() 34 | 35 | set(_options) 36 | set(_one_value_args KEY OUTPUT_VARIABLE) 37 | set(_multi_value_args) 38 | cmake_parse_arguments(_get_value_from_config_file "${_options}" "${_one_value_args}" "${_multi_value_args}" ${ARGN}) 39 | 40 | if(NOT _get_value_from_config_file_KEY) 41 | message(FATAL_ERROR "No `KEY` has given in call to `get_value_from_config_file()`") 42 | endif() 43 | if(NOT _get_value_from_config_file_OUTPUT_VARIABLE) 44 | message(FATAL_ERROR "No `OUTPUT_VARIABLE` has given in call to `get_value_from_config_file()`") 45 | endif() 46 | 47 | execute_process( 48 | COMMAND /bin/sh -c ". ${_get_value_from_config_file_FILENAME} && echo \${${_get_value_from_config_file_KEY}}" 49 | OUTPUT_VARIABLE _result 50 | ERROR_QUIET 51 | OUTPUT_STRIP_TRAILING_WHITESPACE 52 | ) 53 | set(${_get_value_from_config_file_OUTPUT_VARIABLE} "${_result}" PARENT_SCOPE) 54 | 55 | endfunction() 56 | 57 | # X-Chewy-RepoBase: https://raw.githubusercontent.com/mutanabbi/chewy-cmake-rep/master/ 58 | # X-Chewy-Path: GetKeyValueFromShellLikeConfig.cmake 59 | # X-Chewy-Version: 1.0 60 | # X-Chewy-Description: Getting values from trivial shell compatible config files 61 | -------------------------------------------------------------------------------- /cmake/modules/GuessBuildType.cmake: -------------------------------------------------------------------------------- 1 | # - Guess appropriate value for CMAKE_BUILD_TYPE if latter is not set 2 | # 3 | # If no CMAKE_BUILD_TYPE provided to `cmake` try to guess it. 4 | # The end-user, who get a tarball, likely wants 5 | # to build a release, but developers (who has VCS dirs on top of a 6 | # source tree), likely wants to build a debug version... 7 | # 8 | 9 | #============================================================================= 10 | # Copyright 2012-2016 by Alex Turbov 11 | # 12 | # Distributed under the OSI-approved BSD License (the "License"); 13 | # see accompanying file LICENSE for details. 14 | # 15 | # This software is distributed WITHOUT ANY WARRANTY; without even the 16 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | # See the License for more information. 18 | #============================================================================= 19 | # (To distribute this file outside of this repository, substitute the full 20 | # License text for the above reference.) 21 | 22 | # If CMAKE_BUILD_TYPE is not set, check for VCS files 23 | if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) 24 | if (EXISTS ${CMAKE_SOURCE_DIR}/.git OR EXISTS ${CMAKE_SOURCE_DIR}/.hg OR EXISTS ${CMAKE_SOURCE_DIR}/.svn) 25 | set(CMAKE_BUILD_TYPE "Debug") 26 | else() 27 | set(CMAKE_BUILD_TYPE "Release") 28 | endif() 29 | message(STATUS "Set configuration to ${CMAKE_BUILD_TYPE}") 30 | endif() 31 | 32 | # X-Chewy-RepoBase: https://raw.githubusercontent.com/mutanabbi/chewy-cmake-rep/master/ 33 | # X-Chewy-Path: GuessBuildType.cmake 34 | # X-Chewy-Version: 1.7 35 | # X-Chewy-Description: Guess build type if not specified explicitly 36 | -------------------------------------------------------------------------------- /cmake/modules/PreparePCHHeader.cmake.in: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2012 by Alex Turbov 2 | # 3 | # Collect a list of foreign headers used in a project as a file to be compiled into PCH 4 | # 5 | 6 | execute_process( 7 | COMMAND find . -maxdepth 1 -type d -a ! -printf "%p|" 8 | COMMAND sed -e "s,\\./,,g" -e "s,\\.|,," -e "s,|$,," 9 | OUTPUT_VARIABLE TOP_LEVEL_SOURCE_DIRS_MASK 10 | OUTPUT_STRIP_TRAILING_WHITESPACE 11 | WORKING_DIRECTORY @CMAKE_SOURCE_DIR@ 12 | ) 13 | # message(STATUS "tldm: ${TOP_LEVEL_SOURCE_DIRS_MASK}") 14 | 15 | execute_process( 16 | COMMAND grep -r -e "^#\\s*include\\s*<.*>" @use_pch_file_include_options@ 17 | @use_pch_file_FILTER_DIRS_COMMAND@ 18 | COMMAND sed -e "s,[^:]*:# *include *<\\(.*\\)>.*$,\\1," 19 | @use_pch_file_FILTER_FILES_COMMAND@ 20 | COMMAND sort 21 | COMMAND uniq -c 22 | COMMAND sort -nr 23 | COMMAND egrep -v "(${TOP_LEVEL_SOURCE_DIRS_MASK})" 24 | COMMAND sed "s,^\\s\\+\\([0-9]\\+\\)\\s\\+\\(.*\\)\\s*$,# include <\\2> // Included \\1 times," 25 | COMMAND awk -F "//" "{ printf(\"%-60s//%s\\n\", $1, $2)}" 26 | OUTPUT_VARIABLE use_pch_file_CONTENT 27 | WORKING_DIRECTORY @CMAKE_SOURCE_DIR@ 28 | ) 29 | 30 | string(RANDOM LENGTH 15 ALPHABET "QWERTYUIOPASDFGHJKLZXCVBNM0123456789" use_pch_file_GUARD) 31 | set(use_pch_file_GUARD "__PCH_${use_pch_file_GUARD}__") 32 | 33 | # Render a PCH file 34 | configure_file(@CMAKE_SOURCE_DIR@/cmake/modules/pch_template.h.in @use_pch_file_PCH_FILE@ @ONLY) 35 | 36 | # kate: hl cmake; 37 | -------------------------------------------------------------------------------- /cmake/modules/TestCMakeLists.txt.in: -------------------------------------------------------------------------------- 1 | set(UNIT_TESTS unit_tests) 2 | 3 | add_boost_tests( 4 | TARGET ${UNIT_TESTS} 5 | SOURCES FIRST_SOURCE_FILE 6 | NO_CATCH_SYSTEM_ERRORS 7 | ) 8 | 9 | target_link_libraries( 10 | ${UNIT_TESTS} 11 | ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY} 12 | ) 13 | -------------------------------------------------------------------------------- /cmake/modules/UsePCHFile.cmake: -------------------------------------------------------------------------------- 1 | # - Function to render a header file that can be used as PCH 2 | # 3 | # `use_pch_file()` will add a target (named 'update-pch-header') to collect 4 | # most used imported (i.e. not from this project) headers 5 | # and generate a file w/ #include directives for all of them. 6 | # 7 | # use_pch_file(PCH_FILE 8 | # [EXCLUDE_DIRS dir1 [... dirN]] 9 | # [EXCLUDE_HEADERS file1 [... fileN]] 10 | # [SOURCE_EXTENSIONS ext1 [... extN]] 11 | # ) 12 | # 13 | # Parameters are: 14 | # 15 | # PCH_FILE -- an output filename to be generated 16 | # EXCLUDE_DIRS -- a list of directories to exclude from scan 17 | # EXCLUDE_HEADERS -- a list of header files to exclude from result PCH file 18 | # SOURCE_EXTENSIONS -- a list of source file extensions to scan 19 | # default is: *.hh, *.cc, *.h, *.c, *.hpp, *.cpp, *.hxx, *.cxx 20 | # 21 | 22 | #============================================================================= 23 | # Copyright 2012-2013 by Alex Turbov 24 | # 25 | # Distributed under the OSI-approved BSD License (the "License"); 26 | # see accompanying file LICENSE for details. 27 | # 28 | # This software is distributed WITHOUT ANY WARRANTY; without even the 29 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 30 | # See the License for more information. 31 | #============================================================================= 32 | # (To distribute this file outside of this repository, substitute the full 33 | # License text for the above reference.) 34 | 35 | set(_USE_PHC_FILE_MODULE_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}") 36 | 37 | function(use_pch_file) 38 | set(oneValueArgs PCH_FILE) 39 | set(multiValueArgs EXCLUDE_DIRS EXCLUDE_HEADERS SOURCE_EXTENSIONS) 40 | cmake_parse_arguments(use_pch_file "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 41 | 42 | if (NOT use_pch_file_PCH_FILE) 43 | message(FATAL_ERROR "PCH_FILE option required to call cmake_parse_arguments()") 44 | endif() 45 | 46 | if(NOT use_pch_file_SOURCE_EXTENSIONS) 47 | set(use_pch_file_SOURCE_EXTENSIONS hh cc hpp cpp h c hxx cxx) 48 | endif() 49 | 50 | if (use_pch_file_EXCLUDE_DIRS) 51 | foreach(_dir ${use_pch_file_EXCLUDE_DIRS}) 52 | set(use_pch_file_EXCLUDE_DIRS_REGEX "${use_pch_file_EXCLUDE_DIRS_REGEX}${_pipe}${_dir}") 53 | set(_pipe "|") 54 | endforeach() 55 | unset(_pipe) 56 | set( 57 | use_pch_file_FILTER_DIRS_COMMAND 58 | "COMMAND egrep -v \"(${use_pch_file_EXCLUDE_DIRS_REGEX})/\"" 59 | ) 60 | endif() 61 | 62 | if (use_pch_file_EXCLUDE_HEADERS) 63 | foreach(_dir ${use_pch_file_EXCLUDE_HEADERS}) 64 | set(use_pch_file_EXCLUDE_HEADERS_REGEX "${use_pch_file_EXCLUDE_HEADERS_REGEX}${_pipe}${_dir}") 65 | set(_pipe "|") 66 | endforeach() 67 | unset(_pipe) 68 | set( 69 | use_pch_file_FILTER_FILES_COMMAND 70 | "COMMAND egrep -v \"(${use_pch_file_EXCLUDE_HEADERS_REGEX})\"" 71 | ) 72 | endif() 73 | 74 | foreach(ext ${use_pch_file_SOURCE_EXTENSIONS}) 75 | set(use_pch_file_include_options "${use_pch_file_include_options} --include=*.${ext}") 76 | endforeach() 77 | 78 | # Render a script to produce a header file w/ most used external headers 79 | configure_file( 80 | ${_USE_PHC_FILE_MODULE_BASE_DIR}/PreparePCHHeader.cmake.in 81 | ${CMAKE_BINARY_DIR}/PreparePCHHeader.cmake 82 | @ONLY 83 | ) 84 | 85 | add_custom_target( 86 | update-pch-header 87 | COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/PreparePCHHeader.cmake 88 | MAIN_DEPENDENCY ${CMAKE_BINARY_DIR}/PreparePCHHeader.cmake 89 | COMMENT "Updating ${use_pch_file_PCH_FILE}" 90 | ) 91 | endfunction() 92 | 93 | # X-Chewy-RepoBase: https://raw.githubusercontent.com/mutanabbi/chewy-cmake-rep/master/ 94 | # X-Chewy-Path: UsePCHFile.cmake 95 | # X-Chewy-Version: 2.11 96 | # X-Chewy-Description: Add Precompiled Header Support 97 | # X-Chewy-AddonFile: PreparePCHHeader.cmake.in 98 | # X-Chewy-AddonFile: pch_template.h.in 99 | -------------------------------------------------------------------------------- /cmake/modules/class.tpl.in: -------------------------------------------------------------------------------- 1 | [+ AutoGen5 template hh=%s.@SKELETON_HEADER_EXT@ cc=%s.@SKELETON_IMPL_EXT@ 2 | # 3 | # Copyright 2004-2013, by Alex Turbov 4 | # This is the autogen template file to produce header and module for new class. 5 | # Check $(top_srcdir)/README for details of usage. 6 | # 7 | +] 8 | /** 9 | * \file 10 | * 11 | * \brief Class \c [+ FOR namespace +][+ namespace +]::[+ ENDFOR +][+ classname +] [+ IF ( == (suffix) "hh") +](interface)[+ ELSE +](implementation)[+ ENDIF +] 12 | * 13 | * \date [+ (shell "LC_ALL=C date") +] -- Initial design 14 | */[+ IF (== (get "no_license") "no") +] 15 | /* 16 | [+ (license-full "@PROJECT_LICENSE@" "@PROJECT_PREFIX@" " * " "@PROJECT_OWNER@" "@PROJECT_YEARS@") +] 17 | */[+ ENDIF +][+ IF (== (get "use_pragma") "no") +][+ define incguard 18 | +]__[+ (string-upcase (get "guard_base")) +]__[+ (string-upcase (get "filename")) +]_HH__[+ 19 | enddef +][+ ENDIF +][+ 20 | IF ( == (suffix) "hh") +] 21 | [+(out-move (sprintf "%s.@SKELETON_HEADER_EXT@" (get "filename"))) +] 22 | [+ IF (== (get "use_pragma") "no") +]#ifndef [+ incguard +] 23 | # define [+ incguard +][+ELSE+]#pragma once[+ENDIF+] 24 | 25 | // Project specific includes 26 | 27 | // Standard includes 28 | 29 | [+define ns-list +][+ FOR namespace " " +]namespace [+ namespace +] {[+ ENDFOR +][+ enddef +][+ 30 | define ns-rev-list +][+ FOR reverse_namespace ", " +][+ reverse_namespace +][+ ENDFOR +][+ enddef +][+ 31 | ns-list +] 32 | 33 | /** 34 | * \brief [Type brief class description here] 35 | * 36 | * [More detailed description here] 37 | * 38 | */ 39 | class [+ classname +] 40 | { 41 | public: 42 | /// Default constructor 43 | [+ classname +]() {} 44 | /// Destructor 45 | virtual ~[+ classname +]() {} 46 | }; 47 | 48 | [+ ns-close +]// namespace [+ ns-rev-list +][+ IF (== (get "use_pragma") "no") +] 49 | #endif // [+ incguard +][+ ENDIF +][+ 50 | (set-writable 1) +][+ 51 | ELSE +] 52 | 53 | // Project specific includes 54 | #include <[+ subdir +]/[+ filename +].@SKELETON_HEADER_EXT@> 55 | 56 | // Standard includes 57 | 58 | [+ ns-list +] 59 | 60 | [+ ns-close +]// namespace [+ ns-rev-list +][+ 61 | (set-writable 1) +][+ 62 | ENDIF +] 63 | -------------------------------------------------------------------------------- /cmake/modules/class_tester.tpl.in: -------------------------------------------------------------------------------- 1 | [+ AutoGen5 template cc=%s.@SKELETON_IMPL_EXT@ 2 | # 3 | # Copyright 2004-2013, by Alex Turbov 4 | # This is the autogen template file to produce unit-tests module for new fixture tester class. 5 | # 6 | +] 7 | /** 8 | * \file 9 | * 10 | * \brief Class tester for \c [+ classname +] 11 | * 12 | * \date [+ (shell "LC_ALL=C date") +] -- Initial design 13 | */[+ IF (== (get "no_license") "no") +] 14 | /* 15 | [+ (license-full "@PROJECT_LICENSE@" "@PROJECT_PREFIX@" " * " "@PROJECT_OWNER@" "@PROJECT_YEARS@") +] 16 | */[+ ENDIF +] 17 | 18 | // Project specific includes 19 | #include <[+ classname +].@SKELETON_HEADER_EXT@> 20 | 21 | // Standard includes 22 | #include 23 | // Include the following file if u need to validate some text results 24 | // #include 25 | #include 26 | 27 | // Uncomment if u want to use boost test output streams. 28 | // Then just output smth to it and validate an output by 29 | // BOOST_CHECK(out_stream.is_equal("Test text")) 30 | // using boost::test_tools::output_test_stream; 31 | 32 | // Your first test function :) 33 | BOOST_AUTO_TEST_CASE([+ classname +]@TESTNAME_SUFFIX@) 34 | { 35 | // Your test code here... 36 | } 37 | [+(set-writable 1) +] 38 | -------------------------------------------------------------------------------- /cmake/modules/compile_test.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # ATTENTION DO NOT EDIT! This file was generated by CMake! 3 | # 4 | 5 | # Set variables from "parent" context 6 | set(add_compile_tests_DEBUG "@add_compile_tests_DEBUG@") 7 | set(_compile_options @_compile_options@) 8 | set(_compiler "@_compiler@") 9 | set(_fake_cc "@_fake_cc@") 10 | set(_output_dir "@_output_dir@") 11 | set(_src_name "@_src_name@") 12 | set(_src_rel_dir "@_src_rel_dir@") 13 | 14 | # Prepare test file to compile 15 | file(WRITE "${_fake_cc}" "#include <${_src_rel_dir}/${_src_name}>\nint main(){return 0;}\n") 16 | 17 | # Finalize compiler command line 18 | string(REPLACE "" "${_fake_cc}.o" _compiler_options "${_compile_options}") 19 | string(REPLACE "" "${_fake_cc}" _compiler_options "${_compiler_options}") 20 | 21 | # Try to compile 22 | execute_process( 23 | COMMAND ${_compiler} ${_compiler_options} 24 | RESULT_VARIABLE _result 25 | OUTPUT_VARIABLE _output 26 | ERROR_VARIABLE _error 27 | ) 28 | 29 | string(REPLACE ";" " " _compiler_options "${_compiler_options}") 30 | 31 | # Check the result 32 | if(NOT _result EQUAL 0) 33 | # Write messages log to file 34 | file( 35 | WRITE "${_fake_cc}.log" 36 | "Checking ${_src_rel_dir}/${_src_name}\n" 37 | "Command line:\n" 38 | "${_compiler} ${_compiler_options}\n" 39 | "---[ Output ]---\n" 40 | "${_output}\n" 41 | "---[ Errors ]---\n" 42 | "${_error}" 43 | ) 44 | message(FATAL_ERROR "Compile check failed: ${_src_rel_dir}/${_src_name}") 45 | elseif(NOT add_compile_tests_DEBUG) 46 | # Cleanup results 47 | file(REMOVE "${_fake_cc}" "${_fake_cc}.o" "${_fake_cc}.log") 48 | endif() 49 | -------------------------------------------------------------------------------- /cmake/modules/libclang_get_version.cpp: -------------------------------------------------------------------------------- 1 | // kate: hl C++11; 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | CXString version_str = clang_getClangVersion(); 8 | std::cout << clang_getCString(version_str); 9 | clang_disposeString(version_str); 10 | return 0; 11 | } 12 | -------------------------------------------------------------------------------- /cmake/modules/new_class_tester_post.cmake.in: -------------------------------------------------------------------------------- 1 | # 2 | # Do some actions after test skeleton generation 3 | # 4 | # ATTENTION DO NOT EDIT! THIS FILE WAS AUTOGENERATED BY CMAKE! 5 | # 6 | 7 | if(NOT EXISTS "${_top_srcdir}/${_subdir}/CMakeLists.txt") 8 | if(_md OR _mkdir) 9 | configure_file( 10 | "@_DSGT_BASE_DIR@/TestCMakeLists.txt.in" 11 | "${_top_srcdir}/${_subdir}/CMakeLists.txt" 12 | ) 13 | message(STATUS "Do not forget to update an upper level CMakeLists.txt with 'add_subdirrectory(tests)'") 14 | endif() 15 | endif() 16 | -------------------------------------------------------------------------------- /cmake/modules/pch_template.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * DO NOT EDIT! THIS FILE WAS GENERATED BY `make update-pch-header` 3 | * 4 | */ 5 | #ifndef @use_pch_file_GUARD@ 6 | # define @use_pch_file_GUARD@ 7 | @use_pch_file_CONTENT@ 8 | #endif // @use_pch_file_GUARD@ 9 | -------------------------------------------------------------------------------- /cmake/modules/unit_tests_main_skeleton.cc.in: -------------------------------------------------------------------------------- 1 | /* 2 | * ATTENTION DO NOT EDIT! 3 | * 4 | * This file was generated by CMake from cmake/modules/unit_tests_main_skeleton.cc.in 5 | */ 6 | 7 | #cmakedefine BOOST_TEST_MODULE @BOOST_TEST_MODULE@ 8 | #cmakedefine BOOST_AUTO_TEST_MAIN @BOOST_AUTO_TEST_MAIN@ 9 | #cmakedefine BOOST_TEST_DYN_LINK @BOOST_TEST_DYN_LINK@ 10 | 11 | // Standard includes 12 | #include <@BOOST_TEST_INCLUDE@> 13 | 14 | // kate: hl C++; 15 | -------------------------------------------------------------------------------- /contrib/sample.sanitizer-rules: -------------------------------------------------------------------------------- 1 | [Kate C++ Helper plugin: Completion Sanitizer Rules] 2 | SanitizeRules[$e]=BOOST_(PP_[A-Z_]+_(\\\\d+|[A-Z])|.*_HPP(_INCLUDED)?$$|[A-Z_]+_(AUX|DETAIL)_),(\\, ((boost::detail::variant|mpl_)::)?(void_|na))*><$$replace-with$$>>, (&|&&)<$$replace-with$$>\\\\1, ([\\\\)\\\\]>])<$$replace-with$$>\\\\1,basic_string<$$replace-with$$>string,std::(deque|list|vector)<(.*)\\, std::allocator<\\\\2\\\\s?>\\\\s?><$$replace-with$$>std::\\\\1<\\\\2> 3 | -------------------------------------------------------------------------------- /src/choose_from_list_dialog.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::ChooseFromListDialog (implementation) 5 | * 6 | * \date Tue Dec 25 05:49:02 MSK 2012 -- Initial design 7 | */ 8 | /* 9 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * See the GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program. If not, see . 21 | */ 22 | 23 | // Project specific includes 24 | #include "choose_from_list_dialog.h" 25 | 26 | // Standard includes 27 | #include 28 | #include 29 | #include 30 | #include 31 | 32 | namespace kate { 33 | //BEGIN ChooseFromListDialog 34 | ChooseFromListDialog::ChooseFromListDialog(QWidget* parent) 35 | : KDialog(parent) 36 | { 37 | setModal(true); 38 | setButtons(KDialog::Ok | KDialog::Cancel); 39 | showButtonSeparator(true); 40 | setCaption(i18nc("@title:window", "Choose Header File to Open")); 41 | 42 | m_list = new KListWidget{this}; 43 | setMainWidget(m_list); 44 | 45 | connect(m_list, SIGNAL(executed(QListWidgetItem*)), this, SLOT(accept())); 46 | } 47 | 48 | QString ChooseFromListDialog::selectHeaderToOpen(QWidget* parent, const QStringList& strings) 49 | { 50 | KConfigGroup gcg(KGlobal::config(), "CppHelperChooserDialog"); 51 | ChooseFromListDialog dialog(parent); 52 | dialog.m_list->addItems(strings); // append gien items to the list 53 | if (!strings.isEmpty()) // if strings list isn't empty 54 | { 55 | dialog.m_list->setCurrentRow(0); // select 1st row in the list 56 | dialog.m_list->setFocus(Qt::TabFocusReason); // and give focus to it 57 | } 58 | dialog.restoreDialogSize(gcg); // restore dialog geometry from config 59 | 60 | QStringList result; 61 | if (dialog.exec() == QDialog::Accepted) // if user accept smth 62 | { 63 | // grab seleted items into a result list 64 | for (const QListWidgetItem* item : dialog.m_list->selectedItems()) 65 | result.append(item->text()); 66 | } 67 | dialog.saveDialogSize(gcg); // write dialog geometry to config 68 | gcg.sync(); 69 | if (result.empty()) 70 | return QString{}; 71 | assert("The only file expected" && result.size() == 1u); 72 | return result[0]; 73 | } 74 | //END ChooseFromListDialog 75 | } // namespace kate 76 | // kate: hl C++/Qt4; 77 | -------------------------------------------------------------------------------- /src/choose_from_list_dialog.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::ChooseFromListDialog (interface) 5 | * 6 | * \date Tue Dec 25 05:49:02 MSK 2012 -- Initial design 7 | */ 8 | /* 9 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * See the GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program. If not, see . 21 | */ 22 | 23 | #pragma once 24 | 25 | // Project specific includes 26 | 27 | // Standard includes 28 | #include 29 | 30 | class KListWidget; 31 | 32 | namespace kate { 33 | 34 | /** 35 | * \brief [Type brief class description here] 36 | * 37 | * [More detailed description here] 38 | * 39 | */ 40 | class ChooseFromListDialog : public KDialog 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | ChooseFromListDialog(QWidget*); 46 | static QString selectHeaderToOpen(QWidget*, const QStringList&); 47 | 48 | private: 49 | KListWidget* m_list; 50 | }; 51 | 52 | } // namespace kate 53 | // kate: hl C++/Qt4; 54 | -------------------------------------------------------------------------------- /src/clang/compiler_options.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::clang::compiler_options (implementation) 5 | * 6 | * \date Fri Oct 25 05:11:29 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "compiler_options.h" 30 | 31 | // Standard includes 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace kate { namespace clang { 38 | 39 | compiler_options::compiler_options(const QStringList& options) 40 | { 41 | m_shadow.resize(options.size()); 42 | for (auto i = 0; i < options.size(); ++i) 43 | m_shadow[i] = options.at(i).toUtf8(); 44 | } 45 | 46 | std::vector compiler_options::get() const 47 | { 48 | std::vector pointers{m_shadow.size(), nullptr}; 49 | for (auto i = 0u; i < m_shadow.size(); ++i) 50 | pointers[i] = m_shadow[i].constData(); 51 | return pointers; 52 | } 53 | 54 | compiler_options& compiler_options::operator<<(const QString& option) 55 | { 56 | m_shadow.emplace_back(option.toUtf8()); 57 | return *this; 58 | } 59 | 60 | /// Make \c location printable to Qt debug streams 61 | QDebug operator<<(QDebug dbg, const compiler_options& opts) 62 | { 63 | QString result; 64 | for (const auto& o : opts.m_shadow) 65 | result += o; 66 | dbg.space() << result; 67 | return dbg.space(); 68 | } 69 | 70 | /// Make \c location printable to C++ streams 71 | std::ostream& operator<<(std::ostream& os, const compiler_options& opts) 72 | { 73 | std::string result; 74 | for (const auto& o : opts.m_shadow) 75 | result += o.constData(); 76 | os << result; 77 | return os; 78 | } 79 | 80 | }} // namespace clang, kate 81 | -------------------------------------------------------------------------------- /src/clang/compiler_options.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::clang::compiler_options (interface) 5 | * 6 | * \date Fri Oct 25 05:11:29 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | class QDebug; 39 | class QString; 40 | class QStringList; 41 | 42 | namespace kate { namespace clang { 43 | 44 | class compiler_options; 45 | 46 | /// Make \c location printable to Qt debug streams 47 | QDebug operator<<(QDebug, const compiler_options&); 48 | 49 | /// Make \c location printable to C++ streams 50 | std::ostream& operator<<(std::ostream&, const compiler_options&); 51 | 52 | /** 53 | * \brief A wrapper class to hide ugly underlaid details of compiler options. 54 | * 55 | * The origin of a "problem": Qt uses \c QString to manage strings, which is UCS4 encoded. 56 | * Clang-c API uses (surprise) plain C arrays. So to convert a \c QStringList (a typical way 57 | * to hold a list of strings) to a required form, some dirty work has to be done... 58 | * 59 | */ 60 | class compiler_options 61 | { 62 | public: 63 | /// Default constructor 64 | compiler_options() = default; 65 | /// Make a "shadow" copy of given params 66 | explicit compiler_options(const QStringList&); 67 | /// Default move ctor 68 | compiler_options(compiler_options&&) = default; 69 | /// Default move-assign operator 70 | compiler_options& operator=(compiler_options&&) = default; 71 | /// Delete copy ctor 72 | compiler_options(const compiler_options&) = delete; 73 | /// Delete copy-assign operator 74 | compiler_options& operator=(const compiler_options&) = delete; 75 | 76 | /// Get options understandable by clang-c API 77 | std::vector get() const; 78 | 79 | /// Append option 80 | compiler_options& operator<<(const QString&); 81 | 82 | private: 83 | friend QDebug operator<<(QDebug, const compiler_options&); 84 | friend std::ostream& operator<<(std::ostream&, const compiler_options&); 85 | 86 | std::deque m_shadow; 87 | }; 88 | 89 | }} // namespace clang, kate 90 | -------------------------------------------------------------------------------- /src/clang/debug.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::clang::debug (interface) 5 | * 6 | * \date Sun Oct 6 23:31:57 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "disposable.h" 32 | #include "kind_of.h" 33 | #include "location.h" 34 | 35 | // Standard includes 36 | #include 37 | 38 | namespace kate { namespace clang { 39 | 40 | /// \name Debug streaming support for various clang types 41 | //@{ 42 | 43 | inline QDebug operator<<(QDebug dbg, const CXFile file) 44 | { 45 | DCXString filename = {clang_getFileName(file)}; 46 | dbg.nospace() << clang_getCString(filename); 47 | return dbg.space(); 48 | } 49 | 50 | inline QDebug operator<<(QDebug dbg, const DCXString& c) 51 | { 52 | dbg.nospace() << clang_getCString(c); 53 | return dbg.space(); 54 | } 55 | 56 | inline QDebug operator<<(QDebug dbg, const CXCursor& c) 57 | { 58 | auto kind = kind_of(c); 59 | DCXString csp_str = {clang_getCursorDisplayName(c)}; 60 | dbg.nospace() << location(c) << ": entity:" << csp_str << ", kind:" << toString(kind); 61 | return dbg.space(); 62 | } 63 | //@} 64 | 65 | }} // namespace clang, kate 66 | -------------------------------------------------------------------------------- /src/clang/diagnostic_message.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::clang::diagnostic_message (interface) 5 | * 6 | * \date Fri Nov 8 21:14:58 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "location.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | 37 | namespace kate { namespace clang { 38 | 39 | /** 40 | * Structure to hold info about diagnostic message 41 | * 42 | * \note Qt4 has a problem w/ rvalue references in signal/slots, 43 | * so default copy ctor and assign operator needed :( 44 | */ 45 | struct diagnostic_message 46 | { 47 | /// Severity level 48 | enum class type 49 | { 50 | debug 51 | , info 52 | , warning 53 | , error 54 | , cutset 55 | }; 56 | 57 | location m_location; ///< Location in source code 58 | QString m_text; ///< Diagnostic message text 59 | type m_type; ///< Type of the record 60 | 61 | /// \c record class must be default constructible 62 | diagnostic_message() = default; 63 | /// Make a \c record from parts 64 | diagnostic_message(location&&, QString&&, type) noexcept; 65 | /// Make a \c record w/ message and given type (and empty location) 66 | diagnostic_message(const QString&, type) noexcept; 67 | /// Make a \c record w/ message and given type (and empty location) 68 | diagnostic_message(QString&&, type) noexcept; 69 | /// Move ctor 70 | diagnostic_message(diagnostic_message&&) noexcept; 71 | /// Move-assign operator 72 | diagnostic_message& operator=(diagnostic_message&&) noexcept; 73 | /// Default copy ctor 74 | diagnostic_message(const diagnostic_message&) = default; 75 | /// Default copy-assign operator 76 | diagnostic_message& operator=(const diagnostic_message&) = default; 77 | }; 78 | 79 | inline diagnostic_message::diagnostic_message( 80 | const QString& text 81 | , diagnostic_message::type t 82 | ) noexcept 83 | : m_text(text) 84 | , m_type(t) 85 | { 86 | } 87 | 88 | inline diagnostic_message::diagnostic_message( 89 | QString&& text 90 | , diagnostic_message::type t 91 | ) noexcept 92 | : m_type(t) 93 | { 94 | m_text.swap(text); 95 | } 96 | 97 | inline diagnostic_message::diagnostic_message( 98 | location&& loc 99 | , QString&& text 100 | , const diagnostic_message::type t 101 | ) noexcept 102 | : m_location(std::move(loc)) 103 | , m_type(t) 104 | { 105 | m_text.swap(text); 106 | } 107 | 108 | inline diagnostic_message::diagnostic_message(diagnostic_message&& other) noexcept 109 | : m_location(std::move(other.m_location)) 110 | , m_type(other.m_type) 111 | { 112 | m_text.swap(other.m_text); 113 | } 114 | 115 | inline auto diagnostic_message::operator=(diagnostic_message&& other) noexcept -> diagnostic_message& 116 | { 117 | assert("R U INSANE? ;-)" && &other != this); 118 | m_location = std::move(other.m_location); 119 | m_text.swap(other.m_text); 120 | m_type = other.m_type; 121 | return *this; 122 | } 123 | 124 | }} // namespace clang, kate 125 | -------------------------------------------------------------------------------- /src/clang/disposable.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::clang::disposable (interface) 5 | * 6 | * \date Sun Oct 6 22:26:42 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | #include 34 | #include 35 | 36 | namespace kate { namespace clang { 37 | 38 | /** 39 | * \brief RAII helper to release various clang resources 40 | */ 41 | template 42 | class disposable 43 | { 44 | public: 45 | disposable(T value) : m_value(value) {} 46 | ~disposable() 47 | { 48 | DisposeFn(m_value); 49 | } 50 | /// Delete copy ctor 51 | disposable(const disposable&) = delete; 52 | /// Delete copy-assign operator 53 | disposable& operator=(const disposable&) = delete; 54 | /// Implicit conversion to \c T 55 | operator T() const 56 | { 57 | return m_value; 58 | } 59 | 60 | private: 61 | T m_value; 62 | }; 63 | 64 | /** 65 | * \brief RAII helper to release various clang resources spicified as pointers 66 | */ 67 | template 68 | class disposable 69 | { 70 | public: 71 | disposable(T* value) : m_value(value) {} 72 | ~disposable() 73 | { 74 | DisposeFn(m_value); 75 | } 76 | /// Delete move ctor 77 | disposable(disposable&&) = delete; 78 | /// Delete move-assign operator 79 | disposable& operator=(disposable&&) = delete; 80 | /// Implicit conversion to \c T* 81 | operator T*() const 82 | { 83 | return m_value; 84 | } 85 | /// Get access to underlaid pointer 86 | T* operator ->() const 87 | { 88 | return m_value; 89 | } 90 | 91 | private: 92 | T* m_value; 93 | }; 94 | 95 | typedef disposable DCXIndex; 96 | typedef disposable DCXString; 97 | typedef disposable DCXTranslationUnit; 98 | typedef disposable DCXDiagnostic; 99 | typedef disposable DCXIndexAction; 100 | typedef disposable DCXCodeCompleteResults; 101 | 102 | }} // namespace clang, kate 103 | -------------------------------------------------------------------------------- /src/clang/kind_of.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief A set of overloads of \c kate::clang::kind_of for various clang types 5 | * 6 | * \date Sun Oct 6 23:31:41 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | #include 34 | 35 | namespace kate { namespace clang { 36 | 37 | /// \name Functions to get kind of various clang entities in a unified way 38 | //@{ 39 | 40 | inline auto kind_of(const CXCursor& c) 41 | { 42 | return clang_getCursorKind(c); 43 | } 44 | 45 | inline auto kind_of(const CXIdxEntityInfo& e) 46 | { 47 | return e.kind; 48 | } 49 | 50 | inline auto kind_of(const CXType& t) 51 | { 52 | return t.kind; 53 | } 54 | 55 | inline auto kind_of(CXCompletionString completion_string, unsigned chunk_number) 56 | { 57 | return clang_getCompletionChunkKind(completion_string, chunk_number); 58 | } 59 | //@} 60 | 61 | /** 62 | * \c CXIdxEntityCXXTemplateKind has meaning only for a limited set of \c CXIdxEntityKind value. 63 | * This function return \c true if \c CXIdxEntityInfo::templateKind member can be accessed, 64 | * \c false otherwise. 65 | */ 66 | inline auto may_apply_template_kind(const CXIdxEntityKind kind) 67 | { 68 | switch (kind) 69 | { 70 | case CXIdxEntity_Function: 71 | case CXIdxEntity_Struct: 72 | case CXIdxEntity_CXXClass: 73 | case CXIdxEntity_CXXStaticMethod: 74 | case CXIdxEntity_CXXInstanceMethod: 75 | case CXIdxEntity_CXXConstructor: 76 | case CXIdxEntity_CXXConversionFunction: 77 | case CXIdxEntity_CXXTypeAlias: 78 | return true; 79 | default: 80 | break; 81 | } 82 | return false; 83 | } 84 | 85 | }} // namespace clang, kate 86 | -------------------------------------------------------------------------------- /src/clang/location.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::clang::location (implementation) 5 | * 6 | * \date Sun Oct 6 23:23:51 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "location.h" 30 | #include "disposable.h" 31 | 32 | // Standard includes 33 | #include 34 | 35 | namespace kate { namespace clang { 36 | 37 | location::location(const CXIdxLoc loc) 38 | { 39 | CXIdxClientFile file; 40 | unsigned line; 41 | unsigned column; 42 | unsigned offset; 43 | clang_indexLoc_getFileLocation(loc, &file, nullptr, &line, &column, &offset); 44 | if (line == 0) 45 | throw exception::invalid(); 46 | if (file == nullptr) 47 | throw exception::invalid("No index file has attached to a source location"); 48 | DCXString filename = {clang_getFileName(static_cast(file))}; 49 | m_file = clang_getCString(filename); 50 | assert("Sanity check" && m_file.isValid() && !m_file.isEmpty()); 51 | m_file.cleanPath(); 52 | m_line = line; 53 | m_column = column; 54 | m_offset = offset; 55 | } 56 | 57 | location::location(const CXSourceLocation loc) 58 | { 59 | CXFile file; 60 | unsigned line; 61 | unsigned column; 62 | unsigned offset; 63 | clang_getSpellingLocation(loc, &file, &line, &column, &offset); 64 | if (file == nullptr) 65 | throw exception::invalid("No file has attached to a source location"); 66 | DCXString filename = {clang_getFileName(static_cast(file))}; 67 | m_file = clang_getCString(filename); 68 | assert("Sanity check" && m_file.isValid() && !m_file.isEmpty()); 69 | m_file.cleanPath(); 70 | m_line = line; 71 | m_column = column; 72 | m_offset = offset; 73 | } 74 | 75 | }} // namespace clang, kate 76 | -------------------------------------------------------------------------------- /src/clang/to_string.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Bunch of overloads to convert various clang types to \c QString or \c std::string 5 | * 6 | * \date Sun Oct 6 23:31:48 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "disposable.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | 37 | namespace kate { namespace clang { 38 | 39 | /// \name Convert various clang types to \c QString and \c std::string 40 | //@{ 41 | 42 | /// Get a human readable string of \c CXString 43 | inline QString toString(const DCXString& str) 44 | { 45 | auto* cstr = clang_getCString(str); 46 | if (cstr) 47 | return QString{cstr}; 48 | return QString{}; 49 | } 50 | inline std::string to_string(const DCXString& str) 51 | { 52 | auto* cstr = clang_getCString(str); 53 | if (cstr) 54 | return std::string{cstr}; 55 | return std::string{}; 56 | } 57 | 58 | /// Get a human readable string of \c CXFile 59 | inline QString toString(const CXFile file) 60 | { 61 | return toString(DCXString{clang_getFileName(file)}); 62 | } 63 | inline std::string to_string(const CXFile file) 64 | { 65 | return to_string(DCXString{clang_getFileName(file)}); 66 | } 67 | 68 | /// Get a human readable string of \c CXCursorKind 69 | inline QString toString(const CXCursorKind v) 70 | { 71 | return toString(DCXString{clang_getCursorKindSpelling(v)}); 72 | } 73 | inline std::string to_string(const CXCursorKind v) 74 | { 75 | return to_string(DCXString{clang_getCursorKindSpelling(v)}); 76 | } 77 | 78 | /// Get a human readable string of \c CXType 79 | inline QString toString(const CXType t) 80 | { 81 | return toString(DCXString{clang_getTypeSpelling(t)}); 82 | } 83 | inline std::string to_string(const CXType t) 84 | { 85 | return to_string(DCXString{clang_getTypeSpelling(t)}); 86 | } 87 | 88 | /// Get a human readable string of \c CXTypeKind 89 | inline QString toString(const CXTypeKind t) 90 | { 91 | return toString(DCXString{clang_getTypeKindSpelling(t)}); 92 | } 93 | inline std::string to_string(const CXTypeKind t) 94 | { 95 | return to_string(DCXString{clang_getTypeKindSpelling(t)}); 96 | } 97 | 98 | /// Get a human readable string of \c CXCompletionChunkKind 99 | QString toString(CXCompletionChunkKind); 100 | std::string to_string(CXCompletionChunkKind); 101 | 102 | /// Get a human readable string of \c CXIdxEntityKind 103 | QString toString(CXIdxEntityKind); 104 | std::string to_string(CXIdxEntityKind); 105 | 106 | /// Get a human readable string of \c CXIdxEntityCXXTemplateKind 107 | QString toString(CXIdxEntityCXXTemplateKind); 108 | std::string to_string(CXIdxEntityCXXTemplateKind); 109 | 110 | /// Get a human readable string of \c CXLinkageKind 111 | QString toString(CXLinkageKind); 112 | std::string to_string(CXLinkageKind); 113 | 114 | //@} 115 | 116 | }} // namespace clang, kate 117 | -------------------------------------------------------------------------------- /src/clang/unsaved_files_list.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::clang::unsaved_files_list (implementation) 5 | * 6 | * \date Fri Oct 25 05:40:21 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "unsaved_files_list.h" 30 | 31 | // Standard includes 32 | #include 33 | #include 34 | 35 | namespace kate { namespace clang { 36 | 37 | void unsaved_files_list::update(const KUrl& file, const QString& text) 38 | { 39 | if (!m_updating) 40 | initiate_updating(); 41 | 42 | assert("Sanity check" && m_updating); 43 | assert("Sanity check" && !file.toLocalFile().isEmpty()); 44 | 45 | auto it = m_index.find(file); 46 | if (it == end(m_index)) // Is it in a primary index already? 47 | { // (prevent double update) 48 | // No! Try to find it in a previous generation 49 | it = m_index_prev.find(file); 50 | if (it == end(m_index_prev)) 51 | { 52 | // That is really new file: add content to the storage 53 | auto entry_it = m_unsaved_files.emplace( 54 | end(m_unsaved_files) 55 | , file.toLocalFile().toUtf8() 56 | , text.toUtf8() 57 | ); 58 | // ... and update the primary index 59 | m_index.emplace(file, entry_it); 60 | } 61 | else 62 | { 63 | // Ok, lets set a new content to previously existed file 64 | auto tmp = text.toUtf8(); 65 | it->second->second.swap(tmp); 66 | m_index.emplace(file, it->second); 67 | } 68 | } 69 | else 70 | { 71 | // Huh, file already in the new/updated index, 72 | // so lets update the content again 73 | auto tmp = text.toUtf8(); 74 | it->second->second.swap(tmp); 75 | } 76 | } 77 | 78 | void unsaved_files_list::finalize_updating() 79 | { 80 | for (auto it = begin(m_index_prev), last = end(m_index_prev); it != last; ++it) 81 | { 82 | auto existed_it = m_index.find(it->first); 83 | if (existed_it == end(m_index)) 84 | m_unsaved_files.erase(it->second); 85 | } 86 | m_index_prev.clear(); 87 | m_updating = false; 88 | } 89 | 90 | std::vector unsaved_files_list::get() const 91 | { 92 | assert("u must call finalize_updating() before!" && !m_updating); 93 | 94 | auto result = std::vector{m_unsaved_files.size()}; 95 | 96 | auto i = 0u; 97 | for (auto it = begin(m_unsaved_files), last = end(m_unsaved_files); it != last; ++it, ++i) 98 | { 99 | result[i].Filename = it->first.constData(); 100 | result[i].Contents = it->second.constData(); 101 | /// \note Fraking \c QByteArray has \c int as return type of \c size()! IDIOTS!? 102 | result[i].Length = unsigned(it->second.size()); 103 | } 104 | assert("Sanity check" && i == result.size()); 105 | return result; 106 | } 107 | 108 | void unsaved_files_list::initiate_updating() 109 | { 110 | assert("Sanity check" && !m_updating && m_index_prev.empty()); 111 | m_updating = true; 112 | swap(m_index, m_index_prev); 113 | assert("Sanity check" && m_updating && m_index.empty()); 114 | } 115 | 116 | }} // namespace clang, kate 117 | -------------------------------------------------------------------------------- /src/clang/unsaved_files_list.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::clang::unsaved_files_list (interface) 5 | * 6 | * \date Fri Oct 25 05:40:21 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | class QString; 42 | 43 | namespace kate { namespace clang { 44 | 45 | /** 46 | * \brief A wrapper class to hide ugly underlaid details of unsaved 47 | * files list maintanance. 48 | * 49 | * This class actually acts like a cache ;) 50 | * 51 | * \sa About origin of the problem: \c kate::clang::compiler_options 52 | * 53 | */ 54 | class unsaved_files_list 55 | { 56 | public: 57 | /// Defaulted default constructor 58 | unsaved_files_list() = default; 59 | /// Default move ctor 60 | unsaved_files_list(unsaved_files_list&&) = default; 61 | /// Default move-assign operator 62 | unsaved_files_list& operator=(unsaved_files_list&&) = default; 63 | /// Delete copy ctor 64 | unsaved_files_list(const unsaved_files_list&) = delete; 65 | /// Delete copy-assign operator 66 | unsaved_files_list& operator=(const unsaved_files_list&) = delete; 67 | 68 | /// Update unsaved file 69 | void update(const KUrl&, const QString&); 70 | /// No more updates are coming... 71 | void finalize_updating(); 72 | 73 | /// Get a list of unsaved files in clang-c acceptable format 74 | std::vector get() const; 75 | 76 | private: 77 | typedef std::list> list_type; 78 | /// \todo Maybe better to have a sorted vector of pairs: 79 | /// plain C string (filename) to iterator into the list? 80 | typedef std::map uri_index_type; 81 | 82 | void initiate_updating(); 83 | 84 | list_type m_unsaved_files; 85 | uri_index_type m_index; 86 | uri_index_type m_index_prev; 87 | bool m_updating = {false}; 88 | }; 89 | 90 | }} // namespace clang, kate 91 | -------------------------------------------------------------------------------- /src/clang_settings.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | CLangOptionsWidget 4 | 5 | 6 | clang Options 7 | 8 | 9 | 10 | 11 | 12 | Processing Options 13 | 14 | 15 | 16 | 17 | 18 | Session PCH header to compile: 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | Open 35 | 36 | 37 | 38 | 39 | 40 | 41 | Rebuild 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | Additional command line args: 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 1 59 | 1 60 | 61 | 62 | 63 | false 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | KPushButton 75 | QPushButton 76 |
kpushbutton.h
77 |
78 | 79 | KTextEdit 80 | QTextEdit 81 |
ktextedit.h
82 |
83 | 84 | KUrlRequester 85 | QFrame 86 |
kurlrequester.h
87 |
88 |
89 | 90 | 91 |
92 | -------------------------------------------------------------------------------- /src/config.h.in: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Plugin-wide configuration data 5 | * 6 | * \date Thu Mar 8 07:35:59 MSK 2012 -- Initial design 7 | * 8 | * \attention DO NOT EDIT THIS FILE! IT WAS GENERATED BY CMAKE. 9 | */ 10 | /* 11 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 12 | * under the terms of the GNU General Public License as published by the 13 | * Free Software Foundation, either version 3 of the License, or 14 | * (at your option) any later version. 15 | * 16 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 17 | * WITHOUT ANY WARRANTY; without even the implied warranty of 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | * See the GNU General Public License for more details. 20 | * 21 | * You should have received a copy of the GNU General Public License along 22 | * with this program. If not, see . 23 | */ 24 | 25 | #pragma once 26 | 27 | #define PLUGIN_VERSION "@PROJECT_VERSION@" 28 | 29 | // kate: hl c++11; 30 | -------------------------------------------------------------------------------- /src/data/qt4.incset.in: -------------------------------------------------------------------------------- 1 | [SessionIncludeSet] 2 | Name=Qt4 3 | Dirs[$e]=@QT4_INCSET_DIRS@ 4 | -------------------------------------------------------------------------------- /src/database_options.kcfgc: -------------------------------------------------------------------------------- 1 | File=katecpphelperplugin_database_options.kcfg 2 | ClassName=DatabaseOptions 3 | NameSpace=kate 4 | Mutators=true 5 | 6 | -------------------------------------------------------------------------------- /src/detect_compiler_paths.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | DetectCompilerPathsWidget 4 | 5 | 6 | Detect Compiler Paths 7 | 8 | 9 | 10 | 11 | 12 | 13 | 0 14 | 0 15 | 16 | 17 | 18 | <html><head/><body><p>Select your compiler to ask for builtin <tt>#include</tt> paths</p></body></html> 19 | 20 | 21 | Detect Builtin Compiler Paths 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | g++ 31 | 32 | 33 | true 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | clang++ 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | false 53 | 54 | 55 | Other 56 | 57 | 58 | 59 | 60 | 61 | 62 | false 63 | 64 | 65 | Sorry, not implemented yet :-( 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | Qt::Horizontal 77 | 78 | 79 | 80 | 40 81 | 20 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 0 91 | 0 92 | 93 | 94 | 95 | 96 | 100 97 | 0 98 | 99 | 100 | 101 | Add to list 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | KButtonGroup 115 | QGroupBox 116 |
kbuttongroup.h
117 | 1 118 |
119 | 120 | KPushButton 121 | QPushButton 122 |
kpushbutton.h
123 |
124 | 125 | KUrlRequester 126 | QFrame 127 |
kurlrequester.h
128 |
129 |
130 | 131 | 132 |
133 | -------------------------------------------------------------------------------- /src/diagnostic_messages_model.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::DiagnosticMessagesModel (implementation) 5 | * 6 | * \date Sun Aug 11 04:42:02 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "diagnostic_messages_model.h" 30 | 31 | // Standard includes 32 | #include 33 | #include 34 | 35 | namespace kate { 36 | 37 | int DiagnosticMessagesModel::rowCount(const QModelIndex&) const 38 | { 39 | return static_cast(m_records.size()); 40 | } 41 | 42 | int DiagnosticMessagesModel::columnCount(const QModelIndex&) const 43 | { 44 | return 2; 45 | } 46 | 47 | QVariant DiagnosticMessagesModel::data(const QModelIndex& index, const int role) const 48 | { 49 | switch (role) 50 | { 51 | case Qt::DisplayRole: 52 | #if 0 53 | kDebug(DEBUG_AREA) << "Getting diag data: row=" << index.row() << ", col=" << index.column(); 54 | #endif 55 | // Check if requested item has a source code location 56 | // (m_file member must not be empty) 57 | if (!m_records[index.row()].m_location.empty()) 58 | // Form a compiler-like SPAM 59 | return QString("%1:%2:%3: %4").arg( 60 | m_records[index.row()].m_location.file().toLocalFile() 61 | , QString::number(m_records[index.row()].m_location.line()) 62 | , QString::number(m_records[index.row()].m_location.column()) 63 | , m_records[index.row()].m_text 64 | ); 65 | // Just return a message text 66 | return m_records[index.row()].m_text; 67 | case Qt::ForegroundRole: 68 | { 69 | KColorScheme scheme(QPalette::Normal, KColorScheme::Selection); 70 | switch (m_records[index.row()].m_type) 71 | { 72 | case clang::diagnostic_message::type::error: 73 | return scheme.foreground(KColorScheme::NegativeText).color(); 74 | case clang::diagnostic_message::type::warning: 75 | return scheme.foreground(KColorScheme::NeutralText).color(); 76 | case clang::diagnostic_message::type::info: 77 | return scheme.foreground(KColorScheme::PositiveText).color(); 78 | case clang::diagnostic_message::type::debug: 79 | return scheme.foreground(KColorScheme::InactiveText).color(); 80 | default: 81 | break; 82 | } 83 | break; 84 | } 85 | default: 86 | break; 87 | } 88 | return QVariant(); 89 | } 90 | 91 | void DiagnosticMessagesModel::clear() 92 | { 93 | beginResetModel(); 94 | m_records.clear(); 95 | endResetModel(); 96 | } 97 | 98 | } // namespace kate 99 | // kate: hl C++/Qt4; 100 | -------------------------------------------------------------------------------- /src/diagnostic_messages_model.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::DiagnosticMessagesModel (interface) 5 | * 6 | * \date Sun Aug 11 04:42:02 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "clang/diagnostic_message.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | 37 | namespace kate { 38 | 39 | /** 40 | * \brief A mode class to hold diagnostic messages 41 | * 42 | * Data from this class will be displayed in the Diagnostic Messages 43 | * tab of the plugin sidebar. 44 | * 45 | */ 46 | class DiagnosticMessagesModel : public QAbstractListModel 47 | { 48 | Q_OBJECT 49 | 50 | public: 51 | /// Default constructor 52 | DiagnosticMessagesModel() = default; 53 | 54 | clang::location getLocationByIndex(const QModelIndex&) const; 55 | 56 | /// \name QAbstractTableModel interface 57 | //@{ 58 | /// Get rows count 59 | virtual int rowCount(const QModelIndex& = QModelIndex()) const override; 60 | /// Get columns count 61 | virtual int columnCount(const QModelIndex& = QModelIndex()) const override; 62 | /// Get data for given index and role 63 | virtual QVariant data(const QModelIndex&, int = Qt::DisplayRole) const override; 64 | //@} 65 | 66 | /// \name Records manipulation 67 | //@{ 68 | /// Append a diagnostic record to the model 69 | void append(clang::diagnostic_message&&); 70 | /// Append a diagnostic record to the model (bulk version) 71 | template 72 | void append(Iter, Iter); 73 | //@} 74 | 75 | public Q_SLOTS: 76 | void clear(); 77 | 78 | private: 79 | std::deque m_records; ///< Stored records 80 | }; 81 | 82 | inline clang::location DiagnosticMessagesModel::getLocationByIndex(const QModelIndex& index) const 83 | { 84 | return m_records[index.row()].m_location; 85 | } 86 | 87 | /** 88 | * \attention Qt4 has a problem w/ rvalue references in signal/slots ;( 89 | */ 90 | inline void DiagnosticMessagesModel::append(clang::diagnostic_message&& record) 91 | { 92 | beginInsertRows(QModelIndex(), m_records.size(), m_records.size()); 93 | m_records.emplace_back(std::move(record)); 94 | endInsertRows(); 95 | } 96 | 97 | template 98 | inline void DiagnosticMessagesModel::append(Iter first, Iter last) 99 | { 100 | beginInsertRows( 101 | QModelIndex() 102 | , m_records.size() 103 | , m_records.size() + std::distance(first, last) - 1 104 | ); 105 | m_records.insert(end(m_records), first, last); 106 | endInsertRows(); 107 | } 108 | 109 | } // namespace kate 110 | // kate: hl C++/Qt4; 111 | -------------------------------------------------------------------------------- /src/index/combined_index.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::combined_index (interface) 5 | * 6 | * \date Sat Oct 26 11:22:08 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "types.h" 32 | #include "numeric_value_range_processor.h" 33 | 34 | // Standard includes 35 | #include 36 | #include 37 | #include 38 | 39 | class QString; 40 | 41 | namespace Xapian { 42 | class Database; 43 | class Document; 44 | class Query; 45 | } // namespace Xapian 46 | 47 | namespace kate { namespace index { namespace ro { 48 | class database; 49 | } // namespace ro 50 | class document; 51 | 52 | 53 | /** 54 | * \brief Compound searchable database 55 | * 56 | * [More detailed description here] 57 | * 58 | */ 59 | class combined_index 60 | { 61 | public: 62 | /// Iniialize query parser w/ range processors and prefixes 63 | combined_index(); 64 | /// Search over all connected indices 65 | std::pair, doccount> search(const QString&, doccount = 0, doccount = 2000); 66 | 67 | void add_index(ro::database*); ///< Add index to a list of used 68 | void remove_index(ro::database*); ///< Remove index from search 69 | 70 | std::size_t used_indices() const; ///< Get count of used indices 71 | 72 | private: 73 | void recombine_database(); 74 | Xapian::Query parse_query(const std::string&); 75 | 76 | std::vector m_db_list; 77 | std::unique_ptr m_compound_db; 78 | numeric_value_range_processor m_arity_processor; 79 | numeric_value_range_processor m_size_processor; 80 | numeric_value_range_processor m_align_processor; 81 | numeric_value_range_processor m_line_processor; 82 | numeric_value_range_processor m_column_processor; 83 | Xapian::QueryParser m_qp; 84 | }; 85 | 86 | inline std::size_t combined_index::used_indices() const 87 | { 88 | return m_db_list.size(); 89 | } 90 | 91 | }} // namespace index, kate 92 | -------------------------------------------------------------------------------- /src/index/database.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::database (implementation) 5 | * 6 | * \date Wed Oct 9 11:16:43 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "database.h" 30 | 31 | // Standard includes 32 | #include 33 | 34 | namespace kate { namespace index { namespace { namespace meta { 35 | const std::string FILES_MAPPING = "HDRMAPCACHE"; 36 | const std::string DB_ID = "DBID"; 37 | }} // namespace meta, anonymous namespace 38 | 39 | namespace rw { 40 | 41 | database::database(const dbid db_id, const std::string& path) try 42 | : Xapian::WritableDatabase{path, Xapian::DB_CREATE_OR_OPEN} 43 | , details::database{db_id} 44 | { 45 | } 46 | catch (const Xapian::DatabaseError& e) 47 | { 48 | throw exception::database_failure{"Index database [" + path + "] failure: " + e.get_msg()}; 49 | } 50 | 51 | database::~database() 52 | { 53 | try 54 | { 55 | kDebug(DEBUG_AREA) << "Store DB meta [" << id() << "]..."; 56 | set_metadata(meta::DB_ID, serialize(id())); 57 | set_metadata(meta::FILES_MAPPING, headers_map().storeToString()); 58 | } 59 | catch (const Xapian::DatabaseError& e) 60 | { 61 | kDebug(DEBUG_AREA) << "Fail to store DB meta:" << e.get_msg().c_str(); 62 | } 63 | commit(); 64 | } 65 | 66 | void database::commit() 67 | { 68 | try 69 | { 70 | kDebug(DEBUG_AREA) << "Commiting DB changes..."; 71 | Xapian::WritableDatabase::commit(); 72 | } 73 | catch (const Xapian::DatabaseError& e) 74 | { 75 | /// \todo Handle errors (some of them are recoverable...) 76 | kDebug(DEBUG_AREA) << "Fail to commit:" << e.get_msg().c_str(); 77 | } 78 | } 79 | 80 | } // namespace rw 81 | 82 | namespace ro { 83 | 84 | /** 85 | * \brief Construct from existed database 86 | * 87 | * This constructor assume that database already exists (physically on a disk) 88 | */ 89 | database::database(const std::string& path) try 90 | : Xapian::Database{path} 91 | , details::database{} 92 | { 93 | // Get internal DB ID 94 | auto db_id_str = static_cast(this)->get_metadata(meta::DB_ID); 95 | assert("Sanity check" && !db_id_str.empty()); 96 | m_id = deserialize(db_id_str); 97 | // Load files mapping 98 | auto hdr_cache = static_cast(this)->get_metadata(meta::FILES_MAPPING); 99 | assert("Sanity check" && !hdr_cache.empty()); 100 | m_files_cache.loadFromString(hdr_cache); 101 | } 102 | catch (const Xapian::DatabaseError& e) 103 | { 104 | throw exception::database_failure{"Index database [" + path + "] failure: " + e.get_msg()}; 105 | } 106 | 107 | }}} // namespace ro, index, kate 108 | -------------------------------------------------------------------------------- /src/index/database.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::database (interface) 5 | * 6 | * \date Wed Oct 9 11:16:43 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "details/database.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | #include 37 | 38 | namespace kate { namespace index { 39 | 40 | /// Exceptions group for database classes 41 | struct exception : public std::runtime_error 42 | { 43 | struct database_failure; 44 | explicit exception(const std::string& str) 45 | : std::runtime_error(str) 46 | {} 47 | }; 48 | 49 | struct exception::database_failure : public exception 50 | { 51 | database_failure(const std::string& str) : exception(str) {} 52 | }; 53 | 54 | 55 | /// Read/write access to the indexer database 56 | namespace rw { 57 | /** 58 | * \brief Class \c database w/ read/write access 59 | */ 60 | class database : public Xapian::WritableDatabase, public details::database 61 | { 62 | public: 63 | /// Construct from a database path 64 | database(dbid, const std::string&); 65 | ~database(); 66 | 67 | /// Access header files mapping cache (mutable) 68 | HeaderFilesCache& headers_map(); 69 | /// Commit recent changes to the DB 70 | void commit(); 71 | }; 72 | 73 | inline HeaderFilesCache& database::headers_map() 74 | { 75 | return m_files_cache; 76 | } 77 | 78 | } // namespace rw 79 | 80 | /// Read-only access to the indexer database 81 | namespace ro { 82 | /** 83 | * \brief Class \c database w/ read-only access 84 | */ 85 | class database : public Xapian::Database, public details::database 86 | { 87 | public: 88 | /// Construct from DB path 89 | explicit database(const std::string&); 90 | }; 91 | 92 | }}} // namespace ro, index, kate 93 | -------------------------------------------------------------------------------- /src/index/details/container_info.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::details::container_info (interface) 5 | * 6 | * \date Sun Nov 3 19:01:30 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "../types.h" 32 | 33 | // Standard includes 34 | #include 35 | 36 | namespace kate { namespace index { namespace details { 37 | 38 | /** 39 | * \brief [Type brief class description here] 40 | * 41 | * [More detailed description here] 42 | * 43 | */ 44 | struct container_info 45 | { 46 | std::string m_name; ///< Entity name 47 | std::string m_qname; ///< Fully qualified name 48 | docref m_ref; ///< ref to a container ID in a current DB 49 | 50 | container_info(docref ref, const std::string& name, const std::string& qname) 51 | : m_name{name} 52 | , m_qname{qname} 53 | , m_ref{ref} 54 | {} 55 | /// Default move ctor 56 | container_info(container_info&&) = default; 57 | /// Default move-assign operator 58 | container_info& operator=(container_info&&) = default; 59 | }; 60 | 61 | }}} // namespace details, index, kate 62 | -------------------------------------------------------------------------------- /src/index/details/database.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::details::database (interface) 5 | * 6 | * \date Sun Nov 3 19:00:54 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "../types.h" 32 | #include "../../header_files_cache.h" 33 | 34 | // Standard includes 35 | 36 | namespace kate { namespace index { namespace details { 37 | 38 | /** 39 | * \brief Base class for indexer databases 40 | * 41 | * This class have some common members and provide some basic methods to access them. 42 | */ 43 | class database 44 | { 45 | public: 46 | explicit database(const dbid db_id = 0) : m_id(db_id) {} 47 | virtual ~database() = default; 48 | 49 | /// Access header files mapping cache (immutable) 50 | const HeaderFilesCache& headers_map() const 51 | { 52 | return m_files_cache; 53 | } 54 | /// Get (short) database ID 55 | dbid id() const 56 | { 57 | return m_id; 58 | } 59 | 60 | protected: 61 | HeaderFilesCache m_files_cache; 62 | dbid m_id; 63 | }; 64 | 65 | }}} // namespace details, index, kate 66 | -------------------------------------------------------------------------------- /src/index/document.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::document (interface) 5 | * 6 | * \date Sun Nov 3 19:40:26 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "document_extras.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | 37 | namespace kate { namespace index { 38 | 39 | /** 40 | * \brief Class \c document 41 | */ 42 | class document : public Xapian::Document 43 | { 44 | public: 45 | /// Defaulted default ctor 46 | document() = default; 47 | /// Conversion ctor from \c Xapian::Document 48 | document(Xapian::Document d) : Xapian::Document{d} {} 49 | /// Default copy ctor 50 | document(const document&) = default; 51 | /// Default copy-assign operator 52 | document& operator=(const document&) = default; 53 | 54 | // Brind inherited member into scope 55 | using Xapian::Document::add_boolean_term; 56 | 57 | /// Add boolean term w/ prefix 58 | void add_boolean_term(const std::string& prefix, const std::string& value) 59 | { 60 | if (boost::is_upper()(value[0])) 61 | Xapian::Document::add_boolean_term(prefix + ":" + value); 62 | else 63 | Xapian::Document::add_boolean_term(prefix + value); 64 | // 65 | std::string lowercased = boost::to_lower_copy(value); 66 | Xapian::Document::add_boolean_term(prefix + lowercased); 67 | } 68 | 69 | void add_value(const value_slot slot, const std::string& value) 70 | { 71 | Xapian::Document::add_value(Xapian::valueno(slot), value); 72 | } 73 | 74 | std::string get_value(const value_slot slot) const 75 | { 76 | return Xapian::Document::get_value(Xapian::valueno(slot)); 77 | } 78 | }; 79 | 80 | }} // namespace index, kate 81 | -------------------------------------------------------------------------------- /src/index/document_extras.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::document_extras (implementation) 5 | * 6 | * \date Sun Nov 3 20:39:00 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "document_extras.h" 30 | 31 | // Standard includes 32 | 33 | namespace kate { namespace index { namespace term { 34 | const std::string XACCESS = "XC"; 35 | const std::string XANONYMOUS = "XA"; 36 | const std::string XBASE_CLASS = "XBC"; 37 | const std::string XDECL = "XDL"; 38 | const std::string XIMPLICIT = "XI"; 39 | const std::string XINHERITANCE = "XH"; 40 | const std::string XKIND = "XK"; 41 | const std::string XNAMESPACE = "XNS"; 42 | const std::string XPOD = "XPOD"; 43 | const std::string XREDECLARATION = "XRDL"; 44 | const std::string XREF = "XRF"; 45 | const std::string XSCOPE = "XSC"; 46 | const std::string XSTATIC = "XSTy"; 47 | const std::string XTEMPLATE = "XTP"; 48 | const std::string XVIRTUAL = "XV"; 49 | }}} // namespace term, index, kate 50 | -------------------------------------------------------------------------------- /src/index/document_extras.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::document_extras (interface) 5 | * 6 | * \date Sun Nov 3 20:39:00 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | #include 34 | #include 35 | 36 | namespace kate { namespace index { namespace term { 37 | extern const std::string XACCESS; 38 | extern const std::string XANONYMOUS; 39 | extern const std::string XBASE_CLASS; 40 | extern const std::string XDECL; 41 | extern const std::string XIMPLICIT; 42 | extern const std::string XINHERITANCE; 43 | extern const std::string XKIND; 44 | extern const std::string XPOD; 45 | extern const std::string XREDECLARATION; 46 | extern const std::string XREF; 47 | extern const std::string XSCOPE; 48 | extern const std::string XSTATIC; 49 | extern const std::string XTEMPLATE; 50 | extern const std::string XVIRTUAL; 51 | } // namespace term 52 | 53 | enum class value_slot : Xapian::valueno 54 | { 55 | ACCESS 56 | , ALIGNOF 57 | , ARITY 58 | , BASES 59 | , COLUMN 60 | , DBID 61 | , FILE 62 | , FLAGS 63 | , KIND 64 | , LEXICAL_CONTAINER 65 | , LINE 66 | , NAME 67 | , SCOPE 68 | , SEMANTIC_CONTAINER 69 | , SIZEOF 70 | , TEMPLATE 71 | , TYPE 72 | , VALUE 73 | }; 74 | 75 | }} // namespace index, kate 76 | -------------------------------------------------------------------------------- /src/index/indexer.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::indexer (implementation) 5 | * 6 | * \date Wed Oct 9 11:17:12 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "indexer.h" 30 | #include "details/worker.h" 31 | 32 | // Standard includes 33 | #include 34 | #include 35 | 36 | namespace kate { namespace index { 37 | 38 | indexer::indexer(const dbid id, const std::string& path) 39 | : m_index{clang_createIndex(1, 1)} 40 | , m_db{id, path} 41 | { 42 | } 43 | 44 | indexer::~indexer() 45 | { 46 | if (m_worker_thread) 47 | { 48 | stop(); 49 | m_worker_thread->quit(); 50 | m_worker_thread->wait(); 51 | } 52 | } 53 | 54 | void indexer::start() 55 | { 56 | auto* const t = new QThread{}; 57 | auto* const w = new details::worker{this}; 58 | connect(w, SIGNAL(message(clang::diagnostic_message)), this, SLOT(message_slot(clang::diagnostic_message))); 59 | connect(w, SIGNAL(indexing_uri(QString)), this, SLOT(indexing_uri_slot(QString))); 60 | connect(w, SIGNAL(finished()), this, SLOT(worker_finished_slot())); 61 | connect(this, SIGNAL(stopping()), w, SLOT(request_cancel())); 62 | 63 | connect(w, SIGNAL(finished()), t, SLOT(quit())); 64 | connect(w, SIGNAL(finished()), w, SLOT(deleteLater())); 65 | 66 | connect(t, SIGNAL(started()), w, SLOT(process())); 67 | connect(t, SIGNAL(finished()), t, SLOT(deleteLater())); 68 | connect(t, SIGNAL(finished()), this, SLOT(thread_finished_slot())); 69 | w->moveToThread(t); 70 | t->setObjectName("Indexer"); 71 | t->start(); 72 | m_worker_thread.reset(t); 73 | } 74 | 75 | void indexer::stop() 76 | { 77 | kDebug(DEBUG_AREA) << "Emitting STOP!"; 78 | Q_EMIT(stopping()); 79 | } 80 | 81 | void indexer::message_slot(clang::diagnostic_message msg) 82 | { 83 | Q_EMIT(message(msg)); 84 | } 85 | 86 | void indexer::worker_finished_slot() 87 | { 88 | m_worker_thread->quit(); 89 | } 90 | 91 | void indexer::thread_finished_slot() 92 | { 93 | m_worker_thread->wait(); 94 | m_worker_thread.reset(); 95 | Q_EMIT(finished()); 96 | } 97 | 98 | void indexer::indexing_uri_slot(const QString file) 99 | { 100 | Q_EMIT(indexing_uri(file)); 101 | } 102 | 103 | }} // namespace index, kate 104 | -------------------------------------------------------------------------------- /src/index/indexer.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::indexer (interface) 5 | * 6 | * \date Wed Oct 9 11:17:12 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "database.h" 32 | #include "search_result.h" 33 | #include "types.h" 34 | #include "../clang/disposable.h" 35 | #include "../clang/diagnostic_message.h" 36 | 37 | // Standard includes 38 | #include 39 | #include 40 | #include 41 | 42 | class QThread; 43 | 44 | namespace kate { namespace index { namespace details { 45 | class worker; // fwd decl 46 | } // namespace details 47 | 48 | 49 | /** 50 | * \brief Class to index C/C++ sources into a searchable databse 51 | * 52 | * [More detailed description here] 53 | * 54 | */ 55 | class indexer : public QObject 56 | { 57 | Q_OBJECT 58 | 59 | public: 60 | enum class status 61 | { 62 | stopped 63 | , running 64 | }; 65 | /// Construct an indexer from database path 66 | indexer(dbid, const std::string&); 67 | /// Cleanup everything 68 | ~indexer(); 69 | 70 | indexer& set_compiler_options(std::vector&&); 71 | indexer& set_indexing_options(unsigned); 72 | indexer& add_target(const KUrl&); 73 | 74 | static unsigned default_indexing_options(); 75 | 76 | public Q_SLOTS: 77 | void start(); 78 | void stop(); 79 | 80 | private Q_SLOTS: 81 | void indexing_uri_slot(QString); 82 | void worker_finished_slot(); 83 | void thread_finished_slot(); 84 | void message_slot(clang::diagnostic_message); 85 | 86 | Q_SIGNALS: 87 | void indexing_uri(QString); 88 | void finished(); 89 | void message(clang::diagnostic_message); 90 | void stopping(); 91 | 92 | private: 93 | friend class details::worker; 94 | 95 | std::unique_ptr m_worker_thread; 96 | clang::DCXIndex m_index; 97 | std::vector m_options; 98 | std::vector m_targets; 99 | rw::database m_db; 100 | unsigned m_indexing_options = {default_indexing_options()}; 101 | }; 102 | 103 | inline indexer& indexer::set_compiler_options(std::vector&& options) 104 | { 105 | m_options = std::move(options); 106 | return *this; 107 | } 108 | 109 | inline indexer& indexer::add_target(const KUrl& url) 110 | { 111 | m_targets.emplace_back(url); 112 | return *this; 113 | } 114 | 115 | inline indexer& indexer::set_indexing_options(const unsigned options) 116 | { 117 | m_indexing_options = options; 118 | return *this; 119 | } 120 | 121 | inline unsigned indexer::default_indexing_options() 122 | { 123 | return CXIndexOpt_SkipParsedBodiesInSession | CXIndexOpt_SuppressWarnings; 124 | } 125 | 126 | }} // namespace index, kate 127 | // kate: hl C++/Qt; 128 | -------------------------------------------------------------------------------- /src/index/kind.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::kind (implementation) 5 | * 6 | * \date Wed Oct 30 17:54:10 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "kind.h" 30 | 31 | // Standard includes 32 | #include 33 | #include 34 | 35 | namespace kate { namespace index { namespace { 36 | std::map SYMBOL_KIND_TO_STRING_MAP = 37 | { 38 | {kind::UNEXPOSED, ""} 39 | , {kind::NAMESPACE, "namespace"} 40 | , {kind::NAMESPACE_ALIAS, "namespace alias"} 41 | , {kind::TYPEDEF, "typedef"} 42 | , {kind::TYPE_ALIAS, "type alias"} 43 | , {kind::STRUCT, "struct"} 44 | , {kind::CLASS, "class"} 45 | , {kind::UNION, "union"} 46 | , {kind::ENUM, "enum"} 47 | , {kind::ENUM_CONSTANT, "enum constant"} 48 | , {kind::VARIABLE, "variable"} 49 | , {kind::PARAMETER, "parameter"} 50 | , {kind::FIELD, "field"} 51 | , {kind::BITFIELD, "bit-field"} 52 | , {kind::FUNCTION, "function"} 53 | , {kind::METHOD, "method"} 54 | , {kind::CONSTRUCTOR, "constructor"} 55 | , {kind::DESTRUCTOR, "destructor"} 56 | , {kind::CONVERSTION, "converstion"} 57 | }; 58 | 59 | template 60 | String to_string_impl(const kind k) 61 | { 62 | auto it = SYMBOL_KIND_TO_STRING_MAP.find(k); 63 | assert( 64 | "List of symbol's kind seems changed! Review your code!" 65 | && it != end(SYMBOL_KIND_TO_STRING_MAP) 66 | && SYMBOL_KIND_TO_STRING_MAP.size() == std::size_t(kind::last__) 67 | && k < kind::last__ 68 | ); 69 | return it->second; 70 | } 71 | } // anonymous namespace 72 | 73 | std::string to_string(const kind k) 74 | { 75 | return to_string_impl(k); 76 | } 77 | 78 | QString toString(const kind k) 79 | { 80 | return to_string_impl(k); 81 | } 82 | 83 | }} // namespace index, kate 84 | -------------------------------------------------------------------------------- /src/index/kind.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Enum \c kate::index::kind (interface) 5 | * 6 | * \date Wed Oct 30 17:54:10 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "serialize.h" 32 | 33 | // Standard includes 34 | 35 | class QString; 36 | 37 | namespace kate { namespace index { 38 | 39 | /** 40 | * \brief Enumeration type for possible symbol's kind 41 | */ 42 | enum class kind 43 | { 44 | UNEXPOSED 45 | , NAMESPACE 46 | , NAMESPACE_ALIAS 47 | , TYPEDEF 48 | , TYPE_ALIAS 49 | , STRUCT 50 | , CLASS 51 | , UNION 52 | , ENUM 53 | , ENUM_CONSTANT 54 | , VARIABLE 55 | , PARAMETER 56 | , FIELD 57 | , BITFIELD 58 | , FUNCTION 59 | , METHOD 60 | , CONSTRUCTOR 61 | , DESTRUCTOR 62 | , CONVERSTION 63 | , last__ 64 | }; 65 | 66 | inline std::string serialize(const kind value) 67 | { 68 | return serialize(static_cast(value)); 69 | } 70 | 71 | inline kind deserialize(const std::string& raw) 72 | { 73 | return static_cast(deserialize(raw)); 74 | } 75 | 76 | /// Make a human readable string from \c kind 77 | std::string to_string(kind); 78 | /// Make a human readable string from \c kind 79 | QString toString(kind); 80 | 81 | }} // namespace index, kate 82 | -------------------------------------------------------------------------------- /src/index/numeric_value_range_processor.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::numeric_value_range_processor (implementation) 5 | * 6 | * \date Sun Nov 3 01:32:00 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "numeric_value_range_processor.h" 30 | 31 | // Standard includes 32 | #include 33 | #include 34 | #include 35 | 36 | namespace kate { namespace index { 37 | 38 | Xapian::valueno numeric_value_range_processor::operator()(std::string& start, std::string& end) 39 | { 40 | auto is_valid = true; // Assume everything would be fine :) 41 | // Is prefix specified? 42 | if (!m_prefix.empty()) 43 | { 44 | // Yep, Does it matches? 45 | if (m_prefix.size() < start.size() && boost::starts_with(start, m_prefix)) 46 | boost::erase_head(start, m_prefix.size()); // Erase prefix from start 47 | else 48 | is_valid = false; 49 | } 50 | // Is value-prefix specified? 51 | if (is_valid && !m_value_prefix.empty()) 52 | { 53 | // Yeah, does it matches? 54 | if (m_value_prefix.size() < start.size() && boost::starts_with(start, m_value_prefix)) 55 | { 56 | boost::erase_head(start, m_value_prefix.size());// Erase value-prefix from start 57 | // Possible end value specified w/ prefix as well... 58 | if (boost::starts_with(end, m_value_prefix)) 59 | // Erase value-prefix from end 60 | boost::erase_head(end, m_value_prefix.size()); 61 | } 62 | else is_valid = false; 63 | } 64 | // Is value-suffix specified? 65 | if (is_valid && !m_value_suffix.empty()) 66 | { 67 | // Yeah, does it matches? 68 | if (m_value_suffix.size() < end.size() && boost::ends_with(end, m_value_suffix)) 69 | { 70 | boost::erase_tail(end, m_value_suffix.size()); // Erase value-suffix from end 71 | // Possible start value specified w/ prefix as well... 72 | if (boost::ends_with(start, m_value_suffix)) 73 | // Erase value-suffix from start 74 | boost::erase_tail(start, m_value_suffix.size()); 75 | } 76 | else is_valid = false; 77 | } 78 | 79 | if (is_valid) 80 | { 81 | try 82 | { 83 | // Convert string to doubles 84 | const auto start_value = boost::lexical_cast(start); 85 | const auto end_value = boost::lexical_cast(end); 86 | // Reassign! 87 | // ATTENTION Fracking Xapian's documentation tells nothing about this! 88 | start = Xapian::sortable_serialise(start_value); 89 | end = Xapian::sortable_serialise(end_value); 90 | } 91 | catch (...) 92 | { 93 | is_valid = false; 94 | /// \todo Make some SPAM! 95 | } 96 | } 97 | 98 | return is_valid ? Xapian::valueno(m_slot) : Xapian::BAD_VALUENO; 99 | } 100 | 101 | }} // namespace index, kate 102 | -------------------------------------------------------------------------------- /src/index/numeric_value_range_processor.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::numeric_value_range_processor (interface) 5 | * 6 | * \date Sun Nov 3 01:32:00 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "document_extras.h" 32 | #include "types.h" 33 | 34 | // Standard includes 35 | 36 | namespace kate { namespace index { 37 | 38 | /** 39 | * \brief Custom value range processor for Xapian engine 40 | * 41 | * Implement a numeric range parser w/ prefix/suffix support. 42 | * A numeric parser shipped w/ Xapian can't have prefix and suffix 43 | * at the same time... But we want to have such a feature! 44 | * 45 | */ 46 | class numeric_value_range_processor : public Xapian::ValueRangeProcessor 47 | { 48 | public: 49 | /// Default constructor 50 | explicit numeric_value_range_processor( 51 | const value_slot slot 52 | , const std::string& prefix = std::string() 53 | , const std::string& value_prefix = std::string() 54 | , const std::string& value_suffix = std::string() 55 | ) 56 | : m_prefix{prefix + ":"} 57 | , m_value_prefix{value_prefix} 58 | , m_value_suffix{value_suffix} 59 | , m_slot{slot} 60 | {} 61 | 62 | virtual Xapian::valueno operator()(std::string&, std::string&) override; 63 | 64 | private: 65 | const std::string m_prefix; 66 | const std::string m_value_prefix; 67 | const std::string m_value_suffix; 68 | const value_slot m_slot; 69 | }; 70 | 71 | }} // namespace index, kate 72 | -------------------------------------------------------------------------------- /src/index/search_result.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::search_result (implementation) 5 | * 6 | * \date Sat Nov 2 17:23:30 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "search_result.h" 30 | 31 | // Standard includes 32 | #include 33 | #include 34 | 35 | namespace kate { namespace index { 36 | 37 | search_result::search_result(search_result&& other) noexcept 38 | : m_line{other.m_line} 39 | , m_column{other.m_column} 40 | , m_kind{other.m_kind} 41 | , m_template_kind{other.m_template_kind} 42 | , m_access{other.m_access} 43 | { 44 | m_name.swap(other.m_name); 45 | m_type.swap(other.m_type); 46 | m_file.swap(other.m_file); 47 | m_db_name.swap(other.m_db_name); 48 | m_bases.swap(other.m_bases); 49 | m_scope.swap(other.m_scope); 50 | m_value.swap(other.m_value); 51 | m_sizeof.swap(other.m_sizeof); 52 | m_alignof.swap(other.m_alignof); 53 | m_offsetof.swap(other.m_offsetof); 54 | m_flags.m_flags_as_int = other.m_flags.m_flags_as_int; 55 | } 56 | 57 | search_result& search_result::operator=(search_result&& other) noexcept 58 | { 59 | assert("R u insane? ;-)" && &other != this); 60 | m_name.swap(other.m_name); 61 | m_type.swap(other.m_type); 62 | m_file.swap(other.m_file); 63 | m_db_name.swap(other.m_db_name); 64 | m_bases.swap(other.m_bases); 65 | m_scope.swap(other.m_scope); 66 | m_value.swap(other.m_value); 67 | m_sizeof.swap(other.m_sizeof); 68 | m_alignof.swap(other.m_alignof); 69 | m_offsetof.swap(other.m_offsetof); 70 | m_line = other.m_line; 71 | m_column = other.m_column; 72 | m_kind = other.m_kind; 73 | m_template_kind = other.m_template_kind; 74 | m_access = other.m_access; 75 | m_flags.m_flags_as_int = other.m_flags.m_flags_as_int; 76 | return *this; 77 | } 78 | 79 | }} // namespace index, kate 80 | -------------------------------------------------------------------------------- /src/index/search_result.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::search_result (interface) 5 | * 6 | * \date Sat Nov 2 17:23:30 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "kind.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | namespace kate { namespace index { 41 | 42 | /** 43 | * \brief Structure to hold search result 44 | * 45 | * It contains everything needed for various kind of symbols. 46 | * 47 | */ 48 | struct search_result 49 | { 50 | struct flags 51 | { 52 | union 53 | { 54 | unsigned m_flags_as_int; 55 | struct 56 | { 57 | bool m_static : 1; ///< Symbol has \c static modifier 58 | bool m_virtual : 1; ///< Symbol (function) has dynamic linkage 59 | bool m_const : 1; ///< Symbol has \c const modifier 60 | bool m_volatile : 1; ///< Symbol has \c m_volatile modifier 61 | bool m_pod : 1; ///< Symbol is a POD 62 | bool m_bit_field : 1; ///< Symbol is a bit-field 63 | bool m_decl : 1; ///< Is declaration? (or reference/usage to/of smth) 64 | bool m_redecl : 1; ///< Is redeclaration? (definition) 65 | bool m_implicit : 1; ///< Is implicit? 66 | }; 67 | }; 68 | flags() : m_flags_as_int{0} {} 69 | }; 70 | 71 | /// \attention DO NOT FORGET TO MODIFY MOVE CTOR/ASSIGN, IF U R GOING TO ADD A NEW MEMBER. 72 | 73 | QString m_name; ///< Symbol's name 74 | QString m_type; ///< Symbol's type 75 | QString m_file; ///< Filename of a declaration 76 | QString m_db_name; ///< Name of the indexed collection of this result 77 | boost::optional m_bases; ///< List of base classes 78 | boost::optional m_scope; ///< Full qualified parent scope 79 | boost::optional m_value; ///< Value depended on a symbol's kind 80 | boost::optional m_sizeof; 81 | boost::optional m_alignof; 82 | boost::optional m_offsetof; 83 | boost::optional m_arity; 84 | int m_line = {-1}; 85 | int m_column = {-1}; 86 | kind m_kind; 87 | CXIdxEntityCXXTemplateKind m_template_kind = {CXIdxEntity_NonTemplate}; 88 | CX_CXXAccessSpecifier m_access = {CX_CXXInvalidAccessSpecifier}; 89 | flags m_flags; 90 | 91 | explicit search_result(const kind k) 92 | : m_kind{k} 93 | {} 94 | 95 | /// Delete copy ctor 96 | search_result(const search_result&) = delete; 97 | /// Delete copy-assign operator 98 | search_result& operator=(const search_result&) = delete; 99 | /// Move ctor 100 | search_result(search_result&&) noexcept; 101 | /// Move-assign operator 102 | search_result& operator=(search_result&&) noexcept; 103 | }; 104 | 105 | }} // namespace index, kate 106 | -------------------------------------------------------------------------------- /src/index/serialize.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Simple, straightforward, naive and limited serialization implementation 5 | * 6 | * \date Sat Oct 26 13:38:50 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | namespace kate { namespace index { 40 | 41 | /// Simple serialization helper for integral types 42 | template 43 | typename std::enable_if< 44 | std::is_integral::value || std::is_same::value 45 | , std::string 46 | >::type serialize(const T value) 47 | { 48 | union 49 | { 50 | T as_int; 51 | char buf[sizeof(T)]; 52 | }; 53 | as_int = value; 54 | return std::string{buf, buf + sizeof(T)}; 55 | } 56 | 57 | /// Simple deserialization helper for integral types 58 | template 59 | typename std::enable_if< 60 | std::is_integral::value || std::is_same::value 61 | , T 62 | >::type deserialize(const std::string& raw) 63 | { 64 | assert("Size mismatch" && raw.size() == sizeof(T)); 65 | union 66 | { 67 | T as_int; 68 | char buf[sizeof(T)]; 69 | }; 70 | std::copy(begin(raw), end(raw), buf); 71 | return as_int; 72 | } 73 | 74 | }} // namespace index, kate 75 | -------------------------------------------------------------------------------- /src/index/types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Commonly used types for indexing susbystem 5 | * 6 | * \date Sat Oct 26 12:26:50 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "serialize.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | #include 37 | 38 | namespace kate { namespace index { 39 | 40 | typedef uint32_t fileid; 41 | typedef uint32_t dbid; 42 | typedef Xapian::docid docid; 43 | typedef Xapian::doccount doccount; 44 | 45 | class docref 46 | { 47 | public: 48 | constexpr docref() : m_as_long{0} {} 49 | 50 | constexpr docref(const dbid id1, const docid id2) 51 | : m_db_id{id1} 52 | , m_doc_id{id2} 53 | {} 54 | 55 | dbid database_id() const 56 | { 57 | return m_db_id; 58 | } 59 | docid document_id() const 60 | { 61 | return m_doc_id; 62 | } 63 | 64 | bool is_valid() const 65 | { 66 | return m_db_id && m_doc_id; 67 | } 68 | 69 | static std::string to_string(docref ref) 70 | { 71 | return serialize(ref.m_as_long); 72 | } 73 | static docref from_string(const std::string& raw) 74 | { 75 | auto result = deserialize(raw); 76 | return docref{result}; 77 | } 78 | 79 | private: 80 | constexpr explicit docref(uint64_t val) 81 | : m_as_long{val} 82 | {} 83 | 84 | union 85 | { 86 | uint64_t m_as_long; 87 | struct 88 | { 89 | dbid m_db_id; 90 | docid m_doc_id; 91 | }; 92 | }; 93 | }; 94 | 95 | constexpr Xapian::docid IVALID_DOCUMENT_ID = 0u; ///< Value to indicate an invalid document 96 | 97 | }} // namespace index, kate 98 | -------------------------------------------------------------------------------- /src/index/utils.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::utils (implementation) 5 | * 6 | * \date Sat Oct 26 12:53:39 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "utils.h" 30 | 31 | // Standard includes 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | namespace kate { namespace index { namespace { 38 | const boost::uuids::string_generator UUID_PARSER = {}; 39 | } // anonymous namespace 40 | 41 | dbid make_dbid(const boost::uuids::uuid& uuid) 42 | { 43 | union 44 | { 45 | dbid id; 46 | char buf[sizeof(dbid)]; 47 | }; 48 | for (auto i = 0u; i < sizeof(dbid); ++i) 49 | buf[i] = uuid.data[i]; 50 | return id; 51 | } 52 | 53 | /// \todo Move to the upper level: it has no relation to indexing 54 | boost::uuids::uuid fromString(const QString& uuid_str) 55 | { 56 | assert("UUID string has unexpected size" && uuid_str.size() == 36); 57 | auto uuid_std_str = std::string{uuid_str.toUtf8().constData()}; 58 | return UUID_PARSER(uuid_std_str); 59 | } 60 | 61 | /// \todo Move to the upper level: it has no relation to indexing 62 | QString toString(const boost::uuids::uuid& uuid) 63 | { 64 | auto uuid_std_str = to_string(uuid); 65 | return QString{uuid_std_str.c_str()}; 66 | } 67 | 68 | }} // namespace index, kate 69 | -------------------------------------------------------------------------------- /src/index/utils.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::index::utils (interface) 5 | * 6 | * \date Sat Oct 26 12:53:39 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "types.h" 32 | 33 | // Standard includes 34 | #include 35 | 36 | class QString; 37 | 38 | namespace kate { namespace index { 39 | 40 | /// Helper function to produce (almost) random short DB id 41 | dbid make_dbid(const boost::uuids::uuid&); 42 | 43 | /// Helper function to parse UUID from \c QString 44 | boost::uuids::uuid fromString(const QString&); 45 | 46 | /// Helper function to render UUID to \c QString 47 | QString toString(const boost::uuids::uuid&); 48 | 49 | }} // namespace index, kate 50 | -------------------------------------------------------------------------------- /src/indexing_targets_list_model.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::IndexingTargetsListModel (implementation) 5 | * 6 | * \date Thu Oct 24 01:13:50 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "indexing_targets_list_model.h" 30 | #include "database_manager.h" 31 | 32 | // Standard includes 33 | 34 | namespace kate { 35 | 36 | IndexingTargetsListModel::IndexingTargetsListModel(DatabaseManager& db_mgr) 37 | : QAbstractListModel(nullptr) 38 | , m_db_mgr(db_mgr) 39 | { 40 | } 41 | 42 | int IndexingTargetsListModel::rowCount(const QModelIndex&) const 43 | { 44 | if (m_db_mgr.m_last_selected_index != -1) 45 | { 46 | assert("Sanity check" && std::size_t(m_db_mgr.m_last_selected_index) < m_db_mgr.m_collections.size()); 47 | return m_db_mgr.m_collections[m_db_mgr.m_last_selected_index].m_options->targets().size(); 48 | } 49 | return 0; 50 | } 51 | 52 | QVariant IndexingTargetsListModel::data(const QModelIndex& index, const int role) const 53 | { 54 | if (m_db_mgr.m_last_selected_index != -1 && role == Qt::DisplayRole) 55 | { 56 | const auto& targets = m_db_mgr.m_collections[m_db_mgr.m_last_selected_index].m_options->targets(); 57 | assert("Sanity check" && index.row() < targets.size()); 58 | return targets[index.row()]; 59 | } 60 | return QVariant{}; 61 | } 62 | 63 | } // namespace kate 64 | -------------------------------------------------------------------------------- /src/indexing_targets_list_model.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::IndexingTargetsListModel (interface) 5 | * 6 | * \date Thu Oct 24 01:13:50 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | #include 34 | 35 | namespace kate { 36 | class DatabaseManager; // fwd decl 37 | 38 | /** 39 | * \brief A model class to prepresent a list of configured 40 | * targets to be indexed. 41 | * 42 | * Only \c DatabaseManager can make a new instances of this class. 43 | * 44 | */ 45 | class IndexingTargetsListModel : public QAbstractListModel 46 | { 47 | Q_OBJECT 48 | 49 | public: 50 | /// Construct from a reference to \c DatabaseManager 51 | explicit IndexingTargetsListModel(DatabaseManager&); 52 | 53 | //BEGIN QAbstractListModel interface 54 | virtual int rowCount(const QModelIndex&) const override; 55 | virtual QVariant data(const QModelIndex&, int) const override; 56 | //END QAbstractListModel interface 57 | 58 | /// Add a new empty row 59 | template 60 | void appendNewRow(int, AppendFunctor); 61 | 62 | /// Remove given row 63 | template 64 | void removeRow(const int, RemoveFunctor); 65 | 66 | /// Reset the model 67 | template 68 | void refreshAll(RefreshFunctor); 69 | 70 | private: 71 | DatabaseManager& m_db_mgr; 72 | }; 73 | 74 | template 75 | inline void IndexingTargetsListModel::appendNewRow(const int idx, AppendFunctor fn) 76 | { 77 | beginInsertRows(QModelIndex(), idx, idx); 78 | fn(); 79 | endInsertRows(); 80 | } 81 | 82 | template 83 | inline void IndexingTargetsListModel::removeRow(const int idx, RemoveFunctor fn) 84 | { 85 | beginRemoveRows(QModelIndex(), idx, idx); 86 | fn(idx); 87 | endRemoveRows(); 88 | } 89 | 90 | template 91 | inline void IndexingTargetsListModel::refreshAll(RefreshFunctor fn) 92 | { 93 | beginResetModel(); 94 | fn(); 95 | endResetModel(); 96 | } 97 | 98 | } // namespace kate 99 | -------------------------------------------------------------------------------- /src/indices_table_model.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::IndicesTableModel (interface) 5 | * 6 | * \date Tue Oct 22 16:08:11 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | #include 34 | #include 35 | 36 | namespace kate { 37 | class DatabaseManager; // fwd decl 38 | 39 | /** 40 | * \brief A model class to represent a table w/ configured indices 41 | * used in a current session 42 | * 43 | * Only \c DatabaseManager can make a new instances of this class 44 | * 45 | */ 46 | class IndicesTableModel : public QAbstractItemModel 47 | { 48 | Q_OBJECT 49 | 50 | public: 51 | /// Construct from a weak pointer to \c DatabaseManager 52 | explicit IndicesTableModel(DatabaseManager&); 53 | 54 | //BEGIN QAbstractItemModel interface 55 | virtual int columnCount(const QModelIndex&) const override; 56 | virtual int rowCount(const QModelIndex&) const override; 57 | virtual QModelIndex index(int, int, const QModelIndex&) const override; 58 | virtual QModelIndex parent(const QModelIndex&) const override; 59 | virtual QVariant data(const QModelIndex&, int) const override; 60 | #if 0 61 | virtual QVariant headerData(int, Qt::Orientation, int) const override; 62 | #endif 63 | virtual Qt::ItemFlags flags(const QModelIndex&) const override; 64 | virtual bool setData(const QModelIndex&, const QVariant&, int) override; 65 | //END QAbstractItemModel interface 66 | 67 | template 68 | void appendNewRow(int, AppendFunctor); ///< Add a new empty row 69 | 70 | template 71 | void removeRow(int, RemoveFunctor); ///< Remove a given row 72 | 73 | template 74 | void refreshAll(RefreshFunctor); ///< Reset a whole model 75 | 76 | void refreshRow(int); ///< Notify the model about data changes 77 | 78 | private: 79 | enum column 80 | { 81 | NAME 82 | , last__ 83 | }; 84 | 85 | DatabaseManager& m_db_mgr; 86 | }; 87 | 88 | template 89 | inline void IndicesTableModel::appendNewRow(const int idx, AppendFunctor fn) 90 | { 91 | beginInsertRows(QModelIndex(), idx, idx); 92 | fn(); 93 | endInsertRows(); 94 | } 95 | 96 | template 97 | inline void IndicesTableModel::removeRow(const int idx, RemoveFunctor fn) 98 | { 99 | beginRemoveRows(QModelIndex(), idx, idx); 100 | fn(idx); 101 | endRemoveRows(); 102 | } 103 | 104 | template 105 | inline void IndicesTableModel::refreshAll(RefreshFunctor fn) 106 | { 107 | beginResetModel(); 108 | fn(); 109 | endResetModel(); 110 | } 111 | 112 | } // namespace kate 113 | -------------------------------------------------------------------------------- /src/katecpphelperplugin.desktop.in: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Service 3 | Comment=C/C++ Helper plugin 4 | Name=C++ Helper 5 | Icon=text-x-c++hdr 6 | ServiceTypes=Kate/Plugin 7 | X-KDE-Library=katecpphelperplugin 8 | X-KDE-PluginInfo-Author=Alex Turbov 9 | X-KDE-PluginInfo-Email=i.zaufi@gmail.com 10 | X-KDE-PluginInfo-Website=http://zaufi.github.io/kate-cpp-helper-plugin.html 11 | X-KDE-PluginInfo-Version=@VERSION_STRING@ 12 | X-KDE-PluginInfo-License=GPL 13 | X-KDE-PluginInfo-Depends= 14 | X-KDE-PluginInfo-Category=Editor 15 | X-KDE-ParentApp=kate 16 | X-KDE-Version=4.10 17 | X-Kate-Version=2.9 18 | -------------------------------------------------------------------------------- /src/katecpphelperplugin_database_options.kcfg: -------------------------------------------------------------------------------- 1 | 2 | 6 | kglobalsettings.h 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | false 27 | 28 | 29 | 30 | true 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/path_config.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | PathListConfigWidget 4 | 5 | 6 | Form 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | List of directories to lookup header files 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Select directory to be added to the list 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | Remove selected directory from the list 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Move selected directory up 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | Move selected directory down 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | Clear directories list 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | Qt::Vertical 93 | 94 | 95 | 96 | 0 97 | 0 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | KPushButton 112 | QPushButton 113 |
kpushbutton.h
114 |
115 | 116 | KListWidget 117 | QListWidget 118 |
klistwidget.h
119 |
120 |
121 | 122 | 123 |
124 | -------------------------------------------------------------------------------- /src/sample.sanitizer-rules: -------------------------------------------------------------------------------- 1 | [Kate C++ Helper plugin: Completion Sanitizer Rules] 2 | SanitizeRules[$e]=BOOST_(PP_[A-Z_]+_(\\\\d+|[A-Z])|.*_HPP(_INCLUDED)?$$|[A-Z_]+_(AUX|DETAIL)_),(\\, ((boost::detail::variant|mpl_)::)?(void_|na))*><$$replace-with$$>>, (&|&&)<$$replace-with$$>\\\\1, ([\\\\)\\\\]>])<$$replace-with$$>\\\\1,basic_string<$$replace-with$$>string,std::(deque|list|vector)<(.*)\\, std::allocator<\\\\2\\\\s?>\\\\s?><$$replace-with$$>std::\\\\1<\\\\2> 3 | -------------------------------------------------------------------------------- /src/sanitize_snippet.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Utility functions to sanitize C++ snippets 5 | * 6 | * \date Wed Dec 19 23:17:53 MSK 2012 -- Initial design 7 | */ 8 | /* 9 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * See the GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program. If not, see . 21 | */ 22 | 23 | #pragma once 24 | 25 | // Project specific includes 26 | #include "plugin_configuration.h" 27 | 28 | // Standard includes 29 | #include 30 | 31 | namespace kate { 32 | #if 0 33 | /// Cleanup completion item result type 34 | QString sanitizePrefix(QString&&); 35 | /// Cleanup completion items parameters 36 | QString sanitizeParams(QString&&); 37 | /// Cleanup placeholder from completion item arguments list 38 | QString sanitizePlaceholder(QString&&); 39 | #endif 40 | /// Sanitize a text through a rules set 41 | std::pair sanitize( 42 | QString 43 | , const PluginConfiguration::sanitize_rules_list_type& 44 | ); 45 | 46 | } // kate 47 | // kate: hl C++/Qt4; 48 | -------------------------------------------------------------------------------- /src/search_results_table_model.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::SearchResultsTableModel (interface) 5 | * 6 | * \date Mon Oct 28 09:34:39 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "clang/location.h" 32 | #include "index/kind.h" 33 | #include "index/search_result.h" 34 | 35 | // Standard includes 36 | #include 37 | #include 38 | #include 39 | 40 | namespace kate { 41 | /** 42 | * \brief [Type brief class description here] 43 | * 44 | * [More detailed description here] 45 | * 46 | */ 47 | class SearchResultsTableModel : public QAbstractItemModel 48 | { 49 | Q_OBJECT 50 | 51 | public: 52 | typedef std::vector search_results_list_type; 53 | 54 | //BEGIN QAbstractItemModel interface 55 | virtual int columnCount(const QModelIndex&) const override; 56 | virtual int rowCount(const QModelIndex&) const override; 57 | virtual QModelIndex index(int, int, const QModelIndex&) const override; 58 | virtual QModelIndex parent(const QModelIndex&) const override; 59 | virtual QVariant data(const QModelIndex&, int) const override; 60 | virtual QVariant headerData(int, Qt::Orientation, int) const override; 61 | virtual Qt::ItemFlags flags(const QModelIndex&) const override; 62 | //END QAbstractItemModel interface 63 | 64 | void updateSearchResults(search_results_list_type&&); 65 | const index::search_result& getSearchResult(int) const; 66 | /// Get source file location for given search result number 67 | clang::location getSearchResultLocation(int) const; 68 | 69 | private: 70 | enum column 71 | { 72 | KIND 73 | , NAME 74 | , last__ 75 | }; 76 | search_results_list_type m_results; 77 | }; 78 | 79 | inline void SearchResultsTableModel::updateSearchResults(search_results_list_type&& results) 80 | { 81 | beginResetModel(); 82 | m_results = std::move(results); 83 | endResetModel(); 84 | } 85 | 86 | /** 87 | * Get a search result by offset (index) in the internal collection 88 | * 89 | * \invariant \c row expected to be a valid index in the \c m_results 90 | */ 91 | inline const index::search_result& SearchResultsTableModel::getSearchResult(const int row) const 92 | { 93 | assert("Sanity check" && std::size_t(row) < m_results.size()); 94 | return m_results[row]; 95 | } 96 | 97 | inline clang::location SearchResultsTableModel::getSearchResultLocation(const int row) const 98 | { 99 | const auto& sr = getSearchResult(row); 100 | return clang::location{sr.m_file, sr.m_line, sr.m_column}; 101 | } 102 | 103 | } // namespace kate 104 | -------------------------------------------------------------------------------- /src/string_cast.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Helper functions to convert \c QString to/from \c std::string 5 | * 6 | * \date Thu Oct 31 16:46:12 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "clang/disposable.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | #include 37 | 38 | namespace kate { 39 | 40 | template 41 | typename std::enable_if< 42 | !(std::is_same::value || std::is_same::value) 43 | , OutputString 44 | >::type string_cast(const InputString&); 45 | 46 | template <> 47 | inline std::string string_cast(const QString& str) 48 | { 49 | #ifndef QT_NO_STL 50 | return str.toStdString(); 51 | #else 52 | return str.toUtf8().constData(); 53 | #endif 54 | } 55 | 56 | template<> 57 | inline QString string_cast(const std::string& str) 58 | { 59 | #ifndef QT_NO_STL 60 | return QString::fromStdString(str); 61 | #else 62 | return str.c_str(); 63 | #endif 64 | } 65 | 66 | template 67 | typename std::enable_if< 68 | (std::is_same::value || std::is_same::value) 69 | && std::is_same::value 70 | , OutputString 71 | >::type string_cast(InputString c_str) 72 | { 73 | return c_str ? c_str : OutputString{}; 74 | } 75 | 76 | template 77 | typename std::enable_if< 78 | (std::is_same::value || std::is_same::value) 79 | && std::is_same::value 80 | , OutputString 81 | >::type string_cast(const InputString& str) 82 | { 83 | const auto* const c_str = clang_getCString(str); 84 | return c_str ? c_str : OutputString{}; 85 | } 86 | 87 | } // namespace kate 88 | -------------------------------------------------------------------------------- /src/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(AddBoostTests) 2 | add_definitions(-UQT_NO_STL) 3 | 4 | # Render configuration file (used by unit tests) 5 | configure_file(config.h.in config.h @ONLY) 6 | 7 | # 8 | # Unit tests executable 9 | # 10 | add_boost_tests( 11 | TARGET unit_tests 12 | MODULE BasicTests 13 | DYN_LINK 14 | SOURCES 15 | sanitize_snippet_tester.cpp 16 | utils_tester.cpp 17 | header_files_cache_tester.cpp 18 | translation_unit_tester.cpp 19 | database_manager_tester.cpp 20 | serialize_tester.cpp 21 | index_utils_tester.cpp 22 | unsaved_files_list_tester.cpp 23 | ) 24 | 25 | target_link_libraries( 26 | unit_tests 27 | # NOTE Due a single pass GNU linker `sharedcode4testsmoc` target (library) 28 | # must be specified twice: before and after `sharedcode4tests` 29 | sharedcode4tests 30 | sharedcode4testsmoc 31 | sharedcode4tests 32 | sharedcode4testsmoc 33 | Boost::filesystem 34 | Boost::serialization 35 | Boost::system 36 | Boost::unit_test_framework 37 | libclang 38 | ${KDE4_KTEXTEDITOR_LIBS} 39 | ${KDE4_KFILE_LIBS} 40 | ${XAPIAN_LIBRARIES} 41 | ) 42 | 43 | # 44 | # QTest based indexer unit-tests 45 | # 46 | qt4_wrap_cpp(INDEXER_TESTER_HEADERS_MOC indexer_tester.h) 47 | set( 48 | INDEXER_UNIT_TEST_SOURCES 49 | indexer_tester.cpp 50 | ${INDEXER_TESTER_HEADERS_MOC} 51 | ) 52 | 53 | add_executable( 54 | indexer_unit_tests 55 | ${INDEXER_UNIT_TEST_SOURCES} 56 | ) 57 | 58 | target_link_libraries( 59 | indexer_unit_tests 60 | sharedcode4tests 61 | sharedcode4testsmoc 62 | Boost::filesystem 63 | Boost::serialization 64 | Boost::system 65 | ${KDE4_KTEXTEDITOR_LIBS} 66 | ${KDE4_KDEUI_LIBRARY} 67 | libclang 68 | ${QT_QTTEST_LIBRARY_RELEASE} 69 | ${XAPIAN_LIBRARIES} 70 | ) 71 | 72 | # 73 | # Sample indexer to play w/ it 74 | # 75 | add_executable( 76 | indexing_test 77 | indexing_test.cpp 78 | ) 79 | 80 | target_link_libraries( 81 | indexing_test 82 | sharedcode4tests 83 | ${KDE4_KDECORE_LIBRARY} 84 | libclang 85 | ) 86 | 87 | configure_file(data/test_manifest.in data/fake.db/manifest) 88 | -------------------------------------------------------------------------------- /src/test/config.h.in: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Compile-time configuration data 5 | * 6 | * \attention DO NOT EDIT! 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | 32 | // Standard includes 33 | 34 | #define CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@" 35 | #define CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@" 36 | 37 | // kate: hl C++11; 38 | -------------------------------------------------------------------------------- /src/test/data/classes/test_001.cc: -------------------------------------------------------------------------------- 1 | class foo 2 | {}; 3 | 4 | -------------------------------------------------------------------------------- /src/test/data/classes/test_002.cc: -------------------------------------------------------------------------------- 1 | class foo 2 | {}; 3 | 4 | class bar : public foo {}; 5 | class var : protected foo {}; 6 | -------------------------------------------------------------------------------- /src/test/data/classes/test_003.cc: -------------------------------------------------------------------------------- 1 | template 2 | class foo {}; 3 | 4 | template 5 | struct bar {}; 6 | -------------------------------------------------------------------------------- /src/test/data/classes/test_004.cc: -------------------------------------------------------------------------------- 1 | struct foo 2 | { 3 | template 4 | foo(const int a) 5 | : m_a(a+2) 6 | { 7 | int b = a + 2; 8 | } 9 | int m_a; 10 | }; 11 | -------------------------------------------------------------------------------- /src/test/data/classes/test_005.cc: -------------------------------------------------------------------------------- 1 | template 2 | struct foo {}; 3 | 4 | template 5 | struct foo {}; 6 | 7 | template <> 8 | struct foo {}; 9 | -------------------------------------------------------------------------------- /src/test/data/classes/test_006.cc: -------------------------------------------------------------------------------- 1 | struct foo 2 | { 3 | void bar() {}; 4 | static int b; 5 | static constexpr int c = 123; 6 | }; 7 | 8 | int foo::b = 0; 9 | constexpr int foo::c; -------------------------------------------------------------------------------- /src/test/data/classes/test_007.cc: -------------------------------------------------------------------------------- 1 | class foo 2 | { 3 | int a : 1; 4 | int b : 4; 5 | int c; 6 | bool operator ==(const foo); 7 | }; 8 | 9 | bool operator !=(const foo, const foo); 10 | 11 | bool operator !=(const foo, const foo) 12 | { 13 | auto result = false; 14 | return result; 15 | } 16 | -------------------------------------------------------------------------------- /src/test/data/classes/test_008.cc: -------------------------------------------------------------------------------- 1 | template < 2 | template class TT 3 | , int B 4 | > 5 | class foo 6 | { 7 | template 8 | using type = typename TT::type; 9 | 10 | typedef typename TT::type some; 11 | 12 | using bar = typename TT::type; 13 | }; 14 | -------------------------------------------------------------------------------- /src/test/data/classes/test_009.cc: -------------------------------------------------------------------------------- 1 | struct base 2 | { 3 | virtual void foo() = 0; 4 | }; 5 | 6 | class zoo : virtual public base 7 | { 8 | virtual void foo() override {} 9 | }; 10 | 11 | class bar : virtual public base 12 | { 13 | virtual void zar() = 0; 14 | }; 15 | 16 | class some : public zoo, public bar {}; 17 | -------------------------------------------------------------------------------- /src/test/data/functions/test_001.cc: -------------------------------------------------------------------------------- 1 | void foo(); 2 | -------------------------------------------------------------------------------- /src/test/data/functions/test_002.cc: -------------------------------------------------------------------------------- 1 | void foo() 2 | { 3 | } 4 | 5 | -------------------------------------------------------------------------------- /src/test/data/functions/test_003.cc: -------------------------------------------------------------------------------- 1 | void foo(int, double); 2 | -------------------------------------------------------------------------------- /src/test/data/functions/test_004.cc: -------------------------------------------------------------------------------- 1 | const char* foo(const char* param); 2 | -------------------------------------------------------------------------------- /src/test/data/functions/test_005.cc: -------------------------------------------------------------------------------- 1 | /// Sample 2 | const char* foo(const char* param = nullptr) 3 | { 4 | return param; 5 | } 6 | 7 | -------------------------------------------------------------------------------- /src/test/data/functions/test_006.cc: -------------------------------------------------------------------------------- 1 | struct some {}; 2 | 3 | some foo() 4 | { 5 | return some(); 6 | } 7 | -------------------------------------------------------------------------------- /src/test/data/test_manifest.in: -------------------------------------------------------------------------------- 1 | [options] 2 | name=Test 3 | path=@CMAKE_CURRENT_BINARY_DIR@/data/fake.db 4 | comment=Sample database for unit tests 5 | targets[$e]=@CMAKE_SOURCE_DIR@/src/test/data/sample_files 6 | uuid=deadcafe-0427-4c42-a97c-3d1f4ffe8fde 7 | -------------------------------------------------------------------------------- /src/test/data/typedefs/test_001.cc: -------------------------------------------------------------------------------- 1 | typedef int foo_type; 2 | -------------------------------------------------------------------------------- /src/test/data/typedefs/test_002.cc: -------------------------------------------------------------------------------- 1 | using foo_type = double; 2 | -------------------------------------------------------------------------------- /src/test/data/typedefs/test_003.cc: -------------------------------------------------------------------------------- 1 | template 2 | struct foo 3 | { 4 | typedef typename T::value_type value_type; 5 | }; 6 | -------------------------------------------------------------------------------- /src/test/data/variables/test_001.cc: -------------------------------------------------------------------------------- 1 | /// Some var 2 | int a; 3 | -------------------------------------------------------------------------------- /src/test/data/variables/test_002.cc: -------------------------------------------------------------------------------- 1 | extern int a; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_003.cc: -------------------------------------------------------------------------------- 1 | namespace test { 2 | int a; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/data/variables/test_004.cc: -------------------------------------------------------------------------------- 1 | namespace test { 2 | extern int a; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/data/variables/test_005.cc: -------------------------------------------------------------------------------- 1 | int a = 123; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_006.cc: -------------------------------------------------------------------------------- 1 | extern int a = 123; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_007.cc: -------------------------------------------------------------------------------- 1 | namespace test { 2 | int a = 123; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/data/variables/test_008.cc: -------------------------------------------------------------------------------- 1 | namespace test { 2 | extern int a = 123; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/data/variables/test_009.cc: -------------------------------------------------------------------------------- 1 | namespace { 2 | int a = 123; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/data/variables/test_010.cc: -------------------------------------------------------------------------------- 1 | namespace { 2 | extern int a = 123; 3 | } 4 | -------------------------------------------------------------------------------- /src/test/data/variables/test_011.cc: -------------------------------------------------------------------------------- 1 | thread_local int a; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_012.cc: -------------------------------------------------------------------------------- 1 | volatile int a; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_013.cc: -------------------------------------------------------------------------------- 1 | const int* const a = nullptr; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_014.cc: -------------------------------------------------------------------------------- 1 | const int a = 123; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_015.cc: -------------------------------------------------------------------------------- 1 | constexpr int a = 123; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_016.cc: -------------------------------------------------------------------------------- 1 | static int a; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_017.cc: -------------------------------------------------------------------------------- 1 | const int a = 0; 2 | -------------------------------------------------------------------------------- /src/test/data/variables/test_018.cc: -------------------------------------------------------------------------------- 1 | struct foo 2 | { 3 | const int a = 0; 4 | static const long b = 1; 5 | }; 6 | -------------------------------------------------------------------------------- /src/test/data/variables/test_019.cc: -------------------------------------------------------------------------------- 1 | namespace test { 2 | struct foo 3 | { 4 | int a_member; 5 | static int b_member; 6 | }; 7 | int foo::b_member = 123; 8 | int* b_pointer = &foo::b_member; 9 | } 10 | -------------------------------------------------------------------------------- /src/test/data/variables/test_020.cc: -------------------------------------------------------------------------------- 1 | namespace test { 2 | struct 3 | { 4 | int a_member; 5 | } some; 6 | namespace { 7 | union 8 | { 9 | long as_long; 10 | char buf[sizeof(long)]; 11 | }; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/data/variables/test_021.cc: -------------------------------------------------------------------------------- 1 | enum { value1, value2}; 2 | 3 | enum class test 4 | { 5 | uno = 123 6 | , dos 7 | , tres = 456 8 | }; 9 | 10 | enum class foo : char 11 | { 12 | a = 'a' 13 | , b = 'b' 14 | }; 15 | -------------------------------------------------------------------------------- /src/test/database_manager_tester.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class tester for \c DatabaseManager 5 | * 6 | * \date Sun Oct 13 09:17:11 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "../database_manager.h" 30 | #include 31 | 32 | // Standard includes 33 | #include 34 | #include 35 | // Include the following file if u need to validate some text results 36 | // #include 37 | #include 38 | 39 | // Uncomment if u want to use boost test output streams. 40 | // Then just output smth to it and validate an output by 41 | // BOOST_CHECK(out_stream.is_equal("Test text")) 42 | // using boost::test_tools::output_test_stream; 43 | 44 | using namespace kate; 45 | 46 | namespace { 47 | const char* const SAMPLE_DB_PATH_CSTR = CMAKE_BINARY_DIR "/src/test/data/"; 48 | const KUrl SAMPLE_DB_PATH = QString{SAMPLE_DB_PATH_CSTR}; 49 | } // anonymous namespace 50 | 51 | BOOST_AUTO_TEST_CASE(database_manager_test) 52 | { 53 | BOOST_REQUIRE(boost::filesystem::exists(SAMPLE_DB_PATH_CSTR)); 54 | DatabaseManager mgr{}; 55 | mgr.reset({}, SAMPLE_DB_PATH); 56 | } 57 | -------------------------------------------------------------------------------- /src/test/header_files_cache_tester.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class tester for \c HeaderFilesCache 5 | * 6 | * \date Sat Dec 29 08:00:37 MSK 2012 -- Initial design 7 | */ 8 | /* 9 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 10 | * under the terms of the GNU General Public License as published by the 11 | * Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 15 | * WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 17 | * See the GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License along 20 | * with this program. If not, see . 21 | */ 22 | 23 | // Project specific includes 24 | #include "../header_files_cache.h" 25 | 26 | // Standard includes 27 | #include 28 | // Include the following file if u need to validate some text results 29 | // #include 30 | #include 31 | 32 | // Uncomment if u want to use boost test output streams. 33 | // Then just output smth to it and validate an output by 34 | // BOOST_CHECK(out_stream.is_equal("Test text")) 35 | // using boost::test_tools::output_test_stream; 36 | 37 | using kate::HeaderFilesCache; 38 | 39 | // Your first test function :) 40 | BOOST_AUTO_TEST_CASE(HeaderFilesCacheTest) 41 | { 42 | HeaderFilesCache c; 43 | BOOST_CHECK_EQUAL(c.isEmpty(), true); 44 | BOOST_CHECK_EQUAL(c.size(), 0u); 45 | 46 | { 47 | const HeaderFilesCache& cache = c; 48 | BOOST_CHECK_EQUAL(cache["/some/file/path"], HeaderFilesCache::NOT_FOUND); 49 | } 50 | 51 | const auto ID = c["/some/file/path"]; 52 | const auto SAME_ID = c["/some/file/path"]; 53 | 54 | BOOST_CHECK_EQUAL(c.isEmpty(), false); 55 | BOOST_CHECK_EQUAL(c.size(), 1u); 56 | 57 | BOOST_CHECK_EQUAL(ID, SAME_ID); 58 | { 59 | const HeaderFilesCache& cache = c; 60 | BOOST_CHECK_EQUAL(cache["/some/file/path"], ID); 61 | BOOST_CHECK_EQUAL(cache["/some/file/path"], SAME_ID); 62 | } 63 | 64 | const auto ID2 = c["/some/file/path2"]; 65 | const auto SAME_ID2 = c["/some/file/path2"]; 66 | 67 | BOOST_CHECK_EQUAL(c.isEmpty(), false); 68 | BOOST_CHECK_EQUAL(c.size(), 2u); 69 | 70 | BOOST_CHECK_NE(ID, ID2); 71 | BOOST_CHECK_EQUAL(ID2, SAME_ID2); 72 | { 73 | const HeaderFilesCache& cache = c; 74 | BOOST_CHECK_EQUAL(cache["/some/file/path2"], ID2); 75 | BOOST_CHECK_EQUAL(cache["/some/file/path2"], SAME_ID2); 76 | } 77 | 78 | std::string serialized = c.storeToString(); 79 | { 80 | HeaderFilesCache cache; 81 | 82 | BOOST_CHECK_EQUAL(cache.isEmpty(), true); 83 | BOOST_CHECK_EQUAL(cache.size(), 0u); 84 | 85 | cache.loadFromString(serialized); 86 | 87 | BOOST_CHECK_EQUAL(cache.isEmpty(), false); 88 | BOOST_CHECK_EQUAL(cache.size(), 2u); 89 | 90 | BOOST_CHECK_EQUAL(cache["/some/file/path"], ID); 91 | BOOST_CHECK_EQUAL(cache["/some/file/path"], SAME_ID); 92 | BOOST_CHECK_EQUAL(cache["/some/file/path2"], ID2); 93 | BOOST_CHECK_EQUAL(cache["/some/file/path2"], SAME_ID2); 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /src/test/index_utils_tester.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class tester for \c index_utils 5 | * 6 | * \date Tue Oct 29 06:44:47 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "../index/utils.h" 30 | 31 | // Standard includes 32 | #include 33 | // Include the following file if u need to validate some text results 34 | // #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | 41 | // Uncomment if u want to use boost test output streams. 42 | // Then just output smth to it and validate an output by 43 | // BOOST_CHECK(out_stream.is_equal("Test text")) 44 | // using boost::test_tools::output_test_stream; 45 | 46 | namespace { 47 | const std::string SAMPLE_UUID = "70b9b979-c3c7-4837-a58f-cb7e9461da39"; 48 | const boost::uuids::string_generator UUID_PARSER = {}; 49 | } // anonymous namespace 50 | 51 | using namespace kate::index; 52 | 53 | BOOST_AUTO_TEST_CASE(index_utils_test_1) 54 | { 55 | auto uuid = UUID_PARSER(SAMPLE_UUID); 56 | std::cout << "uuid=" << uuid << std::endl; 57 | auto id = make_dbid(uuid); 58 | std::cout << "id=" << std::hex << id << std::endl; 59 | auto first = std::string{begin(SAMPLE_UUID), begin(SAMPLE_UUID) + 8}; 60 | auto c = bswap_32(std::stoul(first, nullptr, 16)); 61 | std::cout << "id2=" << std::hex << c << std::endl; 62 | BOOST_CHECK_EQUAL(c, id); 63 | } 64 | -------------------------------------------------------------------------------- /src/test/indexer_tester.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class tester for \c indexer 5 | * 6 | * \date Wed Oct 9 11:24:19 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "indexer_tester.h" 30 | #include 31 | 32 | // Standard includes 33 | #include 34 | // Include the following file if u need to validate some text results 35 | // #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | 42 | // Uncomment if u want to use boost test output streams. 43 | // Then just output smth to it and validate an output by 44 | // BOOST_CHECK(out_stream.is_equal("Test text")) 45 | // using boost::test_tools::output_test_stream; 46 | 47 | using namespace kate; 48 | 49 | namespace { 50 | /// \todo Get current compiler paths dynamically! 51 | /// This code already present in the plugin sources, just need to reuse it. 52 | std::vector PARSE_OPTIONS = { 53 | "-x", "c++" 54 | , "-std=c++11" 55 | , "-D__GXX_EXPERIMENTAL_CXX0X__" 56 | , "-I/usr/include" 57 | , "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4" 58 | , "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/x86_64-pc-linux-gnu" 59 | , "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include/g++-v4/backward" 60 | , "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include" 61 | , "-I/usr/local/include" 62 | , "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.9.2/include-fixed" 63 | , "-I" CMAKE_SOURCE_DIR 64 | , "-I" CMAKE_SOURCE_DIR "/src/test/data" 65 | }; 66 | 67 | const std::string SAMPLE_DB_PATH = CMAKE_BINARY_DIR "/src/test/data/test.db"; 68 | const char* const SAMPLE_DIR = CMAKE_SOURCE_DIR "/src/test/data"; 69 | const char* const VAR_TEST_09 = CMAKE_SOURCE_DIR "/src/test/data/variables/test_009.cc"; 70 | const index::dbid SAMPLE_ID = 0xdeadcafe; 71 | 72 | bool make_sure_database_not_exists(const boost::filesystem::path& path) 73 | { 74 | boost::system::error_code error; 75 | boost::filesystem::remove_all(path, error); 76 | return bool(!error); 77 | } 78 | bool s_db_rm_flag = make_sure_database_not_exists(SAMPLE_DB_PATH); 79 | } // anonymous namespace 80 | 81 | void result_waiter::finished() 82 | { 83 | m_done = true; 84 | kDebug() << "--- Got it! ---"; 85 | } 86 | 87 | indexer_tester::indexer_tester() 88 | : m_indexer{SAMPLE_ID, SAMPLE_DB_PATH} 89 | { 90 | QVERIFY(s_db_rm_flag); 91 | connect(&m_indexer, SIGNAL(finished()), &m_res, SLOT(finished())); 92 | } 93 | 94 | void indexer_tester::index_sample_file() 95 | { 96 | kDebug() << "DB path:" << SAMPLE_DB_PATH.c_str(); 97 | m_indexer.set_compiler_options(decltype(PARSE_OPTIONS){PARSE_OPTIONS}) 98 | .add_target(QString{VAR_TEST_09}) 99 | .start() 100 | ; 101 | auto start_time = std::chrono::system_clock::now(); 102 | auto stop_requested = false; 103 | while (!m_res.m_done) 104 | { 105 | QCoreApplication::processEvents(); 106 | if (!stop_requested) 107 | { 108 | auto now = std::chrono::system_clock::now(); 109 | if ((now - start_time) > std::chrono::seconds(2)) 110 | { 111 | kDebug() << "Requesting indexer to stop!"; 112 | m_indexer.stop(); 113 | stop_requested = true; 114 | } 115 | } 116 | } 117 | kDebug() << "Done"; 118 | } 119 | 120 | QTEST_MAIN(indexer_tester) 121 | -------------------------------------------------------------------------------- /src/test/indexer_tester.h: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class \c kate::indexer_tester (interface) 5 | * 6 | * \date Fri Oct 11 02:29:31 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | #pragma once 29 | 30 | // Project specific includes 31 | #include "../index/indexer.h" 32 | 33 | // Standard includes 34 | #include 35 | #include 36 | 37 | namespace kate { 38 | 39 | /** 40 | * \brief Class \c result_waiter 41 | */ 42 | class result_waiter : public QObject 43 | { 44 | Q_OBJECT 45 | 46 | public Q_SLOTS: 47 | void finished(); 48 | 49 | public: 50 | std::atomic m_done = {false}; 51 | }; 52 | 53 | 54 | /** 55 | * \brief [Type brief class description here] 56 | * 57 | * [More detailed description here] 58 | * 59 | */ 60 | class indexer_tester : public QObject 61 | { 62 | Q_OBJECT 63 | 64 | public: 65 | indexer_tester(); 66 | 67 | private Q_SLOTS: 68 | void index_sample_file(); 69 | 70 | private: 71 | index::indexer m_indexer; 72 | result_waiter m_res; 73 | }; 74 | 75 | } // namespace kate 76 | -------------------------------------------------------------------------------- /src/test/serialize_tester.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class tester for \c serialize 5 | * 6 | * \date Sun Oct 27 17:38:10 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "../index/serialize.h" 30 | 31 | // Standard includes 32 | #include 33 | // Include the following file if u need to validate some text results 34 | // #include 35 | #include 36 | 37 | // Uncomment if u want to use boost test output streams. 38 | // Then just output smth to it and validate an output by 39 | // BOOST_CHECK(out_stream.is_equal("Test text")) 40 | // using boost::test_tools::output_test_stream; 41 | 42 | 43 | using namespace kate::index; 44 | 45 | BOOST_AUTO_TEST_CASE(serialize_test) 46 | { 47 | { 48 | auto a = 0xdeadc0de; 49 | auto str = serialize(a); 50 | BOOST_CHECK_EQUAL(str.size(), sizeof(a)); 51 | auto b = deserialize(str); 52 | BOOST_CHECK_EQUAL(a, b); 53 | } 54 | { 55 | auto a = 0xdeadc0defacecafe; 56 | auto str = serialize(a); 57 | BOOST_CHECK_EQUAL(str.size(), sizeof(a)); 58 | auto b = deserialize(str); 59 | BOOST_CHECK_EQUAL(a, b); 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /src/test/translation_unit_tester.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class tester for \c translation_unit 5 | * 6 | * \date Thu Oct 3 22:01:37 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "../translation_unit.h" 30 | #include "../clang/compiler_options.h" 31 | #include "../clang/disposable.h" 32 | #include "../clang/unsaved_files_list.h" 33 | #include 34 | 35 | // Standard includes 36 | #include 37 | // Include the following file if u need to validate some text results 38 | // #include 39 | #include 40 | #include 41 | 42 | // Uncomment if u want to use boost test output streams. 43 | // Then just output smth to it and validate an output by 44 | // BOOST_CHECK(out_stream.is_equal("Test text")) 45 | // using boost::test_tools::output_test_stream; 46 | 47 | using namespace kate; 48 | 49 | namespace { 50 | struct fixture 51 | { 52 | fixture() 53 | { 54 | m_options << "-x" << "c++" 55 | << "-std=c++11" << "-D__GXX_EXPERIMENTAL_CXX0X__" 56 | << "-I/usr/include" 57 | << "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include/g++-v4" 58 | << "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include/g++-v4/x86_64-pc-linux-gnu" 59 | << "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include/g++-v4/backward" 60 | << "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include" 61 | << "-I/usr/local/include" 62 | << "-I/usr/lib/gcc/x86_64-pc-linux-gnu/4.8.1/include-fixed" 63 | << "-I" CMAKE_SOURCE_DIR 64 | << "-I" CMAKE_SOURCE_DIR "/src/test/data" 65 | ; 66 | } 67 | 68 | clang::DCXIndex m_index = {clang_createIndex(0, 1)}; 69 | clang::compiler_options m_options; 70 | }; 71 | 72 | } // anonymous namespace 73 | 74 | BOOST_FIXTURE_TEST_CASE(translation_unit_test_0, fixture) 75 | { 76 | try 77 | { 78 | TranslationUnit unit = { 79 | m_index 80 | , KUrl{CMAKE_SOURCE_DIR "/src/test/data/not-existed.cpp"} 81 | , m_options 82 | , TranslationUnit::defaultEditingParseOptions() 83 | , clang::unsaved_files_list{} 84 | }; 85 | BOOST_FAIL("Unexpected success!"); 86 | } 87 | catch (TranslationUnit::Exception::ParseFailure&) 88 | { 89 | BOOST_TEST_PASSPOINT(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/test/unsaved_files_list_tester.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * \file 3 | * 4 | * \brief Class tester for \c unsaved_files_list 5 | * 6 | * \date Sun Nov 3 00:00:38 MSK 2013 -- Initial design 7 | */ 8 | /* 9 | * Copyright (C) 2011-2013 Alex Turbov, all rights reserved. 10 | * This is free software. It is licensed for use, modification and 11 | * redistribution under the terms of the GNU General Public License, 12 | * version 3 or later 13 | * 14 | * KateCppHelperPlugin is free software: you can redistribute it and/or modify it 15 | * under the terms of the GNU General Public License as published by the 16 | * Free Software Foundation, either version 3 of the License, or 17 | * (at your option) any later version. 18 | * 19 | * KateCppHelperPlugin is distributed in the hope that it will be useful, but 20 | * WITHOUT ANY WARRANTY; without even the implied warranty of 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 22 | * See the GNU General Public License for more details. 23 | * 24 | * You should have received a copy of the GNU General Public License along 25 | * with this program. If not, see . 26 | */ 27 | 28 | // Project specific includes 29 | #include "../clang/unsaved_files_list.h" 30 | 31 | // Standard includes 32 | #include 33 | #include 34 | // Include the following file if u need to validate some text results 35 | // #include 36 | #include 37 | 38 | // Uncomment if u want to use boost test output streams. 39 | // Then just output smth to it and validate an output by 40 | // BOOST_CHECK(out_stream.is_equal("Test text")) 41 | // using boost::test_tools::output_test_stream; 42 | 43 | using namespace kate::clang; 44 | 45 | BOOST_AUTO_TEST_CASE(unsaved_files_list_test) 46 | { 47 | unsaved_files_list l; 48 | { 49 | auto f = l.get(); 50 | BOOST_CHECK(f.empty()); 51 | } 52 | l.update(KUrl{"/test1"}, "test1 content"); 53 | l.finalize_updating(); 54 | { 55 | auto f = l.get(); 56 | BOOST_CHECK_EQUAL(f.size(), 1u); 57 | BOOST_CHECK((boost::equals(f[0].Filename, "/test1"))); 58 | BOOST_CHECK((boost::equals(f[0].Contents, "test1 content"))); 59 | } 60 | l.update(KUrl{"/test2"}, ""); 61 | l.finalize_updating(); 62 | { 63 | auto f = l.get(); 64 | BOOST_CHECK_EQUAL(f.size(), 1u); 65 | BOOST_CHECK((boost::equals(f[0].Filename, "/test2"))); 66 | BOOST_CHECK((boost::equals(f[0].Contents, ""))); 67 | } 68 | l.update(KUrl{"/test1"}, "test1 content"); 69 | l.update(KUrl{"/test2"}, ""); 70 | l.finalize_updating(); 71 | { 72 | auto f = l.get(); 73 | BOOST_CHECK_EQUAL(f.size(), 2u); 74 | } 75 | l.update(KUrl{"/test2"}, "test2 content"); 76 | l.finalize_updating(); 77 | { 78 | auto f = l.get(); 79 | BOOST_CHECK_EQUAL(f.size(), 1u); 80 | BOOST_CHECK((boost::equals(f[0].Filename, "/test2"))); 81 | BOOST_CHECK((boost::equals(f[0].Contents, "test2 content"))); 82 | } 83 | } 84 | 85 | BOOST_AUTO_TEST_CASE(unsaved_files_list_double_update_test) 86 | { 87 | unsaved_files_list l; 88 | l.update(KUrl{"/test1"}, "test1 content"); 89 | l.update(KUrl{"/test1"}, "test2 content"); 90 | { 91 | auto f = l.get(); 92 | BOOST_CHECK_EQUAL(f.size(), 1u); 93 | BOOST_CHECK((boost::equals(f[0].Filename, "/test1"))); 94 | BOOST_CHECK((boost::equals(f[0].Contents, "test2 content"))); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/ui.rc: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 10 | 11 | &File 12 | 13 | 14 | 15 | &Edit 16 | 17 | 18 | 19 | 20 | 21 | 22 | &C++ Helper 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 68 | 69 | 72 | 73 | 76 | 77 | 80 | 81 | 85 | 86 | 90 | 91 | 95 | 96 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /third_party/kde4-kate-interfaces/4.10/kate_export.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of KDE 3 | Copyright (C) 2006 Christian Ehrlicher 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License version 2 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public License 15 | along with this library; see the file COPYING.LIB. If not, write to 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef _KATE_EXPORT_H 21 | #define _KATE_EXPORT_H 22 | 23 | #include 24 | 25 | #ifdef MAKE_KATEINTERFACES_LIB 26 | # define KATEINTERFACES_EXPORT KDE_EXPORT 27 | #else 28 | # if defined _WIN32 || defined _WIN64 29 | # define KATEINTERFACES_EXPORT KDE_IMPORT 30 | # else 31 | # define KATEINTERFACES_EXPORT KDE_EXPORT 32 | # endif 33 | #endif 34 | 35 | #endif // _KATE_EXPORT_H 36 | 37 | -------------------------------------------------------------------------------- /third_party/kde4-kate-interfaces/4.8/kate/pluginmanager.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the KDE project 2 | Copyright (C) 2001 Christoph Cullmann 3 | Copyright (C) 2002 Joseph Wenninger 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License version 2 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public License 15 | along with this library; see the file COPYING.LIB. If not, write to 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef _KATE_PLUGINMANAGER_INCLUDE_ 21 | #define _KATE_PLUGINMANAGER_INCLUDE_ 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace Kate 29 | { 30 | /** 31 | * \brief Interface to the plugin manager. 32 | * 33 | * This interface provides access to Kate's plugin manager. To load a plugin 34 | * call loadPlugin(), to unload a plugin call unloadPlugin(). To check, 35 | * whether a plugin is loaded use plugin(), and to check a plugin's 36 | * availability use pluginAvailable(). 37 | * 38 | * To access the plugin manager use Application::pluginManager(). 39 | * You should never have to create an instance of this class yourself. 40 | * 41 | * \note Usually the Kate application itself loads/unloads the plugins, so 42 | * plugins actually never have to call loadPlugin() or unloadPlugin(). 43 | * 44 | * 45 | * \author Christoph Cullmann \ 46 | * \see Plugin 47 | */ 48 | class KATEINTERFACES_EXPORT PluginManager : public QObject 49 | { 50 | friend class PrivatePluginManager; 51 | 52 | Q_OBJECT 53 | 54 | public: 55 | /** 56 | * Constructor. 57 | * 58 | * Create a new plugin manager. You as a plugin developer should never 59 | * have to create a plugin manager yourself. Get the plugin manager 60 | * with the Application instance. 61 | * \param pluginManager internal usage 62 | */ 63 | PluginManager ( void *pluginManager ); 64 | /** 65 | * Virtual destructor. 66 | */ 67 | virtual ~PluginManager (); 68 | 69 | public: 70 | /** 71 | * Get a plugin with identifier \p name. 72 | * \param name the plugin's name 73 | * \return pointer to the plugin if a plugin with \p name is loaded, 74 | * otherwise NULL 75 | */ 76 | class Plugin *plugin(const QString &name); 77 | 78 | /** 79 | * Check, whether a plugin with \p name exists. 80 | * 81 | * \return \e true if the plugin exists, otherwise \e false 82 | * \todo This method is not used yet, i.e. returns always \e false. 83 | */ 84 | bool pluginAvailable(const QString &name); 85 | 86 | /** 87 | * Load the plugin \p name. 88 | * 89 | * If the plugin does not exist the return value is NULL. 90 | * \param name the plugin name 91 | * \param permanent if \e true the plugin will be loaded at the next Kate 92 | * startup, otherwise it will only be loaded temporarily during the 93 | * current session. 94 | * \return pointer to the plugin on success, otherwise NULL 95 | * \see unloadPlugin() 96 | * \todo This method is not used yet, i.e. returns always NULL. 97 | */ 98 | class Plugin *loadPlugin(const QString &name, bool permanent = true); 99 | 100 | /** 101 | * Unload the plugin \p name. 102 | * 103 | * \param name the plugin name 104 | * \param permanent if \e true the plugin will \e not be loaded on the 105 | * next Kate startup, \e even if it was loaded with permanent set 106 | * to \e true. 107 | * \see loadPlugin() 108 | * \todo This method is not used yet, i.e. does nothing. 109 | */ 110 | void unloadPlugin(const QString &name, bool permanent = true); 111 | 112 | private: 113 | class PrivatePluginManager *d; 114 | }; 115 | 116 | } 117 | 118 | #endif 119 | // kate: space-indent on; indent-width 2; replace-tabs on; 120 | 121 | -------------------------------------------------------------------------------- /third_party/kde4-kate-interfaces/4.8/kate_export.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of KDE 3 | Copyright (C) 2006 Christian Ehrlicher 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License version 2 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public License 15 | along with this library; see the file COPYING.LIB. If not, write to 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef _KATE_EXPORT_H 21 | #define _KATE_EXPORT_H 22 | 23 | #include 24 | 25 | #ifdef MAKE_KATEINTERFACES_LIB 26 | # define KATEINTERFACES_EXPORT KDE_EXPORT 27 | #else 28 | # if defined _WIN32 || defined _WIN64 29 | # define KATEINTERFACES_EXPORT KDE_IMPORT 30 | # else 31 | # define KATEINTERFACES_EXPORT KDE_EXPORT 32 | # endif 33 | #endif 34 | 35 | #endif // _KATE_EXPORT_H 36 | 37 | -------------------------------------------------------------------------------- /third_party/kde4-kate-interfaces/4.9/kate/pluginmanager.h: -------------------------------------------------------------------------------- 1 | /* This file is part of the KDE project 2 | Copyright (C) 2001 Christoph Cullmann 3 | Copyright (C) 2002 Joseph Wenninger 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License version 2 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public License 15 | along with this library; see the file COPYING.LIB. If not, write to 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef _KATE_PLUGINMANAGER_INCLUDE_ 21 | #define _KATE_PLUGINMANAGER_INCLUDE_ 22 | 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace Kate 29 | { 30 | /** 31 | * \brief Interface to the plugin manager. 32 | * 33 | * This interface provides access to Kate's plugin manager. To load a plugin 34 | * call loadPlugin(), to unload a plugin call unloadPlugin(). To check, 35 | * whether a plugin is loaded use plugin(), and to check a plugin's 36 | * availability use pluginAvailable(). 37 | * 38 | * To access the plugin manager use Application::pluginManager(). 39 | * You should never have to create an instance of this class yourself. 40 | * 41 | * \note Usually the Kate application itself loads/unloads the plugins, so 42 | * plugins actually never have to call loadPlugin() or unloadPlugin(). 43 | * 44 | * 45 | * \author Christoph Cullmann \ 46 | * \see Plugin 47 | */ 48 | class KATEINTERFACES_EXPORT PluginManager : public QObject 49 | { 50 | friend class PrivatePluginManager; 51 | 52 | Q_OBJECT 53 | 54 | public: 55 | /** 56 | * Constructor. 57 | * 58 | * Create a new plugin manager. You as a plugin developer should never 59 | * have to create a plugin manager yourself. Get the plugin manager 60 | * with the Application instance. 61 | * \param pluginManager internal usage 62 | */ 63 | PluginManager ( void *pluginManager ); 64 | /** 65 | * Virtual destructor. 66 | */ 67 | virtual ~PluginManager (); 68 | 69 | public: 70 | /** 71 | * Get a plugin with identifier \p name. 72 | * \param name the plugin's name 73 | * \return pointer to the plugin if a plugin with \p name is loaded, 74 | * otherwise NULL 75 | */ 76 | class Plugin *plugin(const QString &name); 77 | 78 | /** 79 | * Check, whether a plugin with \p name exists. 80 | * 81 | * \return \e true if the plugin exists, otherwise \e false 82 | * \todo This method is not used yet, i.e. returns always \e false. 83 | */ 84 | bool pluginAvailable(const QString &name); 85 | 86 | /** 87 | * Load the plugin \p name. 88 | * 89 | * If the plugin does not exist the return value is NULL. 90 | * \param name the plugin name 91 | * \param permanent if \e true the plugin will be loaded at the next Kate 92 | * startup, otherwise it will only be loaded temporarily during the 93 | * current session. 94 | * \return pointer to the plugin on success, otherwise NULL 95 | * \see unloadPlugin() 96 | * \todo This method is not used yet, i.e. returns always NULL. 97 | */ 98 | class Plugin *loadPlugin(const QString &name, bool permanent = true); 99 | 100 | /** 101 | * Unload the plugin \p name. 102 | * 103 | * \param name the plugin name 104 | * \param permanent if \e true the plugin will \e not be loaded on the 105 | * next Kate startup, \e even if it was loaded with permanent set 106 | * to \e true. 107 | * \see loadPlugin() 108 | * \todo This method is not used yet, i.e. does nothing. 109 | */ 110 | void unloadPlugin(const QString &name, bool permanent = true); 111 | 112 | private: 113 | class PrivatePluginManager *d; 114 | }; 115 | 116 | } 117 | 118 | #endif 119 | // kate: space-indent on; indent-width 2; replace-tabs on; 120 | 121 | -------------------------------------------------------------------------------- /third_party/kde4-kate-interfaces/4.9/kate_export.h: -------------------------------------------------------------------------------- 1 | /* 2 | This file is part of KDE 3 | Copyright (C) 2006 Christian Ehrlicher 4 | 5 | This library is free software; you can redistribute it and/or 6 | modify it under the terms of the GNU Library General Public 7 | License version 2 as published by the Free Software Foundation. 8 | 9 | This library is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | Library General Public License for more details. 13 | 14 | You should have received a copy of the GNU Library General Public License 15 | along with this library; see the file COPYING.LIB. If not, write to 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 17 | Boston, MA 02110-1301, USA. 18 | */ 19 | 20 | #ifndef _KATE_EXPORT_H 21 | #define _KATE_EXPORT_H 22 | 23 | #include 24 | 25 | #ifdef MAKE_KATEINTERFACES_LIB 26 | # define KATEINTERFACES_EXPORT KDE_EXPORT 27 | #else 28 | # if defined _WIN32 || defined _WIN64 29 | # define KATEINTERFACES_EXPORT KDE_IMPORT 30 | # else 31 | # define KATEINTERFACES_EXPORT KDE_EXPORT 32 | # endif 33 | #endif 34 | 35 | #endif // _KATE_EXPORT_H 36 | 37 | -------------------------------------------------------------------------------- /third_party/kde4-kate-interfaces/latest: -------------------------------------------------------------------------------- 1 | 4.10 --------------------------------------------------------------------------------