diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e44d7ba..79e8b953 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,12 +36,6 @@ else () set(PLATFORM_INCLUDE "includesLinux.h") endif () -# Settings --------------------------------------------------------------------- - -if (UNIX) - add_definitions(-std=c++11 -Wno-unknown-warning-option -fcolor-diagnostics -DQT_COMPILING_QSTRING_COMPAT_CPP ) -endif () - # Project ---------------------------------------------------------------------- project(${PROJECT_NAME}) @@ -57,6 +51,15 @@ endif() set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +# Settings --------------------------------------------------------------------- + +if (UNIX) + add_definitions(-std=c++11 -Wno-unknown-warning-option -fcolor-diagnostics -DQT_COMPILING_QSTRING_COMPAT_CPP ) +endif () + +# enable fts4 module for sqlite +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS4_PARENTHESIS") + # Clang ------------------------------------------------------------------------ if (UNIX AND APPLE) @@ -622,6 +625,7 @@ elseif (UNIX) add_custom_command( OUTPUT ${TESTGEN_FILE} PRE_BUILD + COMMAND rm -f ${TESTGEN_FILE} COMMAND cd ${PROJECT_SOURCE_DIR} && ${PYTHON_EXECUTABLE} ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --runner=ParenPrinter -o ${TESTGEN_FILE} ${TEST_FILES} COMMENT "Generating unittest code with cxxtestgen" ) diff --git a/bin/app/data/gui/about/icon_close.png b/bin/app/data/gui/about/icon_close.png index 89101f37..a0f3604b 100644 Binary files a/bin/app/data/gui/about/icon_close.png and b/bin/app/data/gui/about/icon_close.png differ diff --git a/bin/app/data/gui/about/logo_aws.png b/bin/app/data/gui/about/logo_aws.png index 3762e5d7..f8c9d0d7 100644 Binary files a/bin/app/data/gui/about/logo_aws.png and b/bin/app/data/gui/about/logo_aws.png differ diff --git a/bin/app/data/gui/about/logo_coati.png b/bin/app/data/gui/about/logo_coati.png index ab69c8ed..1ca11430 100644 Binary files a/bin/app/data/gui/about/logo_coati.png and b/bin/app/data/gui/about/logo_coati.png differ diff --git a/bin/app/data/gui/about/logo_fhs.png b/bin/app/data/gui/about/logo_fhs.png index 560eb794..5bbae4f7 100644 Binary files a/bin/app/data/gui/about/logo_fhs.png and b/bin/app/data/gui/about/logo_fhs.png differ diff --git a/bin/app/data/gui/code_view/images/edit.png b/bin/app/data/gui/code_view/images/edit.png index 9fd89c19..dfb38da2 100644 Binary files a/bin/app/data/gui/code_view/images/edit.png and b/bin/app/data/gui/code_view/images/edit.png differ diff --git a/bin/app/data/gui/code_view/images/maximize_active.png b/bin/app/data/gui/code_view/images/maximize_active.png index 69452eb7..70fb381d 100644 Binary files a/bin/app/data/gui/code_view/images/maximize_active.png and b/bin/app/data/gui/code_view/images/maximize_active.png differ diff --git a/bin/app/data/gui/code_view/images/maximize_inactive.png b/bin/app/data/gui/code_view/images/maximize_inactive.png index 01dcee25..18550e6c 100644 Binary files a/bin/app/data/gui/code_view/images/maximize_inactive.png and b/bin/app/data/gui/code_view/images/maximize_inactive.png differ diff --git a/bin/app/data/gui/code_view/images/minimize_active.png b/bin/app/data/gui/code_view/images/minimize_active.png index e0baf6d1..f423fc42 100644 Binary files a/bin/app/data/gui/code_view/images/minimize_active.png and b/bin/app/data/gui/code_view/images/minimize_active.png differ diff --git a/bin/app/data/gui/code_view/images/minimize_inactive.png b/bin/app/data/gui/code_view/images/minimize_inactive.png index 194efd7c..113d8aa5 100644 Binary files a/bin/app/data/gui/code_view/images/minimize_inactive.png and b/bin/app/data/gui/code_view/images/minimize_inactive.png differ diff --git a/bin/app/data/gui/code_view/images/pattern.png b/bin/app/data/gui/code_view/images/pattern.png index 2f424187..67c2960d 100644 Binary files a/bin/app/data/gui/code_view/images/pattern.png and b/bin/app/data/gui/code_view/images/pattern.png differ diff --git a/bin/app/data/gui/code_view/images/snippet_active.png b/bin/app/data/gui/code_view/images/snippet_active.png index 8119ac0e..ffee534e 100644 Binary files a/bin/app/data/gui/code_view/images/snippet_active.png and b/bin/app/data/gui/code_view/images/snippet_active.png differ diff --git a/bin/app/data/gui/code_view/images/snippet_inactive.png b/bin/app/data/gui/code_view/images/snippet_inactive.png index c8ede05b..92c8145c 100644 Binary files a/bin/app/data/gui/code_view/images/snippet_inactive.png and b/bin/app/data/gui/code_view/images/snippet_inactive.png differ diff --git a/bin/app/data/gui/graph_view/images/arrow.png b/bin/app/data/gui/graph_view/images/arrow.png index dff2a697..dbd989de 100644 Binary files a/bin/app/data/gui/graph_view/images/arrow.png and b/bin/app/data/gui/graph_view/images/arrow.png differ diff --git a/bin/app/data/gui/graph_view/images/bundle.png b/bin/app/data/gui/graph_view/images/bundle.png index 850c2735..7dad7bf4 100644 Binary files a/bin/app/data/gui/graph_view/images/bundle.png and b/bin/app/data/gui/graph_view/images/bundle.png differ diff --git a/bin/app/data/gui/graph_view/images/enum_1.png b/bin/app/data/gui/graph_view/images/enum_1.png index 4e97a001..e23ba3d5 100644 Binary files a/bin/app/data/gui/graph_view/images/enum_1.png and b/bin/app/data/gui/graph_view/images/enum_1.png differ diff --git a/bin/app/data/gui/graph_view/images/enum_2.png b/bin/app/data/gui/graph_view/images/enum_2.png index 0cbb3873..40751b74 100644 Binary files a/bin/app/data/gui/graph_view/images/enum_2.png and b/bin/app/data/gui/graph_view/images/enum_2.png differ diff --git a/bin/app/data/gui/graph_view/images/file.png b/bin/app/data/gui/graph_view/images/file.png index f19d49e3..96ada559 100644 Binary files a/bin/app/data/gui/graph_view/images/file.png and b/bin/app/data/gui/graph_view/images/file.png differ diff --git a/bin/app/data/gui/graph_view/images/macro_1.png b/bin/app/data/gui/graph_view/images/macro_1.png index 82fdc25e..dd956ed2 100644 Binary files a/bin/app/data/gui/graph_view/images/macro_1.png and b/bin/app/data/gui/graph_view/images/macro_1.png differ diff --git a/bin/app/data/gui/graph_view/images/macro_2.png b/bin/app/data/gui/graph_view/images/macro_2.png index 839adfc2..6a29ac9d 100644 Binary files a/bin/app/data/gui/graph_view/images/macro_2.png and b/bin/app/data/gui/graph_view/images/macro_2.png differ diff --git a/bin/app/data/gui/graph_view/images/macro_3.png b/bin/app/data/gui/graph_view/images/macro_3.png index 7e20eec3..8544a179 100644 Binary files a/bin/app/data/gui/graph_view/images/macro_3.png and b/bin/app/data/gui/graph_view/images/macro_3.png differ diff --git a/bin/app/data/gui/graph_view/images/pattern.png b/bin/app/data/gui/graph_view/images/pattern.png index 2f424187..67c2960d 100644 Binary files a/bin/app/data/gui/graph_view/images/pattern.png and b/bin/app/data/gui/graph_view/images/pattern.png differ diff --git a/bin/app/data/gui/graph_view/images/private.png b/bin/app/data/gui/graph_view/images/private.png index d437d2a4..ee30e318 100644 Binary files a/bin/app/data/gui/graph_view/images/private.png and b/bin/app/data/gui/graph_view/images/private.png differ diff --git a/bin/app/data/gui/graph_view/images/protected.png b/bin/app/data/gui/graph_view/images/protected.png index 69d8e7f8..34b235ea 100644 Binary files a/bin/app/data/gui/graph_view/images/protected.png and b/bin/app/data/gui/graph_view/images/protected.png differ diff --git a/bin/app/data/gui/graph_view/images/public.png b/bin/app/data/gui/graph_view/images/public.png old mode 100755 new mode 100644 index cb909b9c..1d9ad7aa Binary files a/bin/app/data/gui/graph_view/images/public.png and b/bin/app/data/gui/graph_view/images/public.png differ diff --git a/bin/app/data/gui/graph_view/images/template.png b/bin/app/data/gui/graph_view/images/template.png index 2ccd921b..a107084d 100644 Binary files a/bin/app/data/gui/graph_view/images/template.png and b/bin/app/data/gui/graph_view/images/template.png differ diff --git a/bin/app/data/gui/graph_view/images/typedef_1.png b/bin/app/data/gui/graph_view/images/typedef_1.png index 88a6d4fe..5172eb4d 100644 Binary files a/bin/app/data/gui/graph_view/images/typedef_1.png and b/bin/app/data/gui/graph_view/images/typedef_1.png differ diff --git a/bin/app/data/gui/graph_view/images/typedef_2.png b/bin/app/data/gui/graph_view/images/typedef_2.png index 2289c971..fec468df 100644 Binary files a/bin/app/data/gui/graph_view/images/typedef_2.png and b/bin/app/data/gui/graph_view/images/typedef_2.png differ diff --git a/bin/app/data/gui/graph_view/images/typedef_3.png b/bin/app/data/gui/graph_view/images/typedef_3.png index eee76dac..5362c845 100644 Binary files a/bin/app/data/gui/graph_view/images/typedef_3.png and b/bin/app/data/gui/graph_view/images/typedef_3.png differ diff --git a/bin/app/data/gui/icon/logo_1024_1024.png b/bin/app/data/gui/icon/logo_1024_1024.png index 27df53ac..d96f3901 100644 Binary files a/bin/app/data/gui/icon/logo_1024_1024.png and b/bin/app/data/gui/icon/logo_1024_1024.png differ diff --git a/bin/app/data/gui/icon/project_256_256.png b/bin/app/data/gui/icon/project_256_256.png index 666d3376..c5f34274 100644 Binary files a/bin/app/data/gui/icon/project_256_256.png and b/bin/app/data/gui/icon/project_256_256.png differ diff --git a/bin/app/data/gui/icon/project_cdb_256_256.png b/bin/app/data/gui/icon/project_cdb_256_256.png index ec7dc5ca..123de25f 100644 Binary files a/bin/app/data/gui/icon/project_cdb_256_256.png and b/bin/app/data/gui/icon/project_cdb_256_256.png differ diff --git a/bin/app/data/gui/icon/project_vs_256_256.png b/bin/app/data/gui/icon/project_vs_256_256.png index db2a9e90..8ccc28fd 100644 Binary files a/bin/app/data/gui/icon/project_vs_256_256.png and b/bin/app/data/gui/icon/project_vs_256_256.png differ diff --git a/bin/app/data/gui/installer/logo_1024_1024.png b/bin/app/data/gui/installer/logo_1024_1024.png index 27df53ac..d96f3901 100644 Binary files a/bin/app/data/gui/installer/logo_1024_1024.png and b/bin/app/data/gui/installer/logo_1024_1024.png differ diff --git a/bin/app/data/gui/refresh_view/images/auto_refresh.png b/bin/app/data/gui/refresh_view/images/auto_refresh.png old mode 100755 new mode 100644 index 0175bce0..6ad64edc Binary files a/bin/app/data/gui/refresh_view/images/auto_refresh.png and b/bin/app/data/gui/refresh_view/images/auto_refresh.png differ diff --git a/bin/app/data/gui/refresh_view/images/refresh.png b/bin/app/data/gui/refresh_view/images/refresh.png old mode 100755 new mode 100644 index 956c4b59..0d216f0e Binary files a/bin/app/data/gui/refresh_view/images/refresh.png and b/bin/app/data/gui/refresh_view/images/refresh.png differ diff --git a/bin/app/data/gui/search_view/images/home.png b/bin/app/data/gui/search_view/images/home.png index b331fb4c..324b7a07 100644 Binary files a/bin/app/data/gui/search_view/images/home.png and b/bin/app/data/gui/search_view/images/home.png differ diff --git a/bin/app/data/gui/search_view/images/search.png b/bin/app/data/gui/search_view/images/search.png old mode 100755 new mode 100644 index 4ae4638c..351984d4 Binary files a/bin/app/data/gui/search_view/images/search.png and b/bin/app/data/gui/search_view/images/search.png differ diff --git a/bin/app/data/gui/splash_blue.png b/bin/app/data/gui/splash_blue.png old mode 100755 new mode 100644 index 85b8a0cf..996ff74b Binary files a/bin/app/data/gui/splash_blue.png and b/bin/app/data/gui/splash_blue.png differ diff --git a/bin/app/data/gui/splash_white.png b/bin/app/data/gui/splash_white.png old mode 100755 new mode 100644 index e9cb70fb..246d7e88 Binary files a/bin/app/data/gui/splash_white.png and b/bin/app/data/gui/splash_white.png differ diff --git a/bin/app/data/gui/statusbar_view/dot.png b/bin/app/data/gui/statusbar_view/dot.png index 9ff022d4..09e3b8a5 100644 Binary files a/bin/app/data/gui/statusbar_view/dot.png and b/bin/app/data/gui/statusbar_view/dot.png differ diff --git a/bin/app/data/gui/undoredo_view/images/arrow_left.png b/bin/app/data/gui/undoredo_view/images/arrow_left.png old mode 100755 new mode 100644 index 3df1439c..ef4d39da Binary files a/bin/app/data/gui/undoredo_view/images/arrow_left.png and b/bin/app/data/gui/undoredo_view/images/arrow_left.png differ diff --git a/bin/app/data/gui/undoredo_view/images/arrow_right.png b/bin/app/data/gui/undoredo_view/images/arrow_right.png old mode 100755 new mode 100644 index 0a80d5ce..068ce5b2 Binary files a/bin/app/data/gui/undoredo_view/images/arrow_right.png and b/bin/app/data/gui/undoredo_view/images/arrow_right.png differ diff --git a/bin/app/data/gui/window/dots.png b/bin/app/data/gui/window/dots.png index 7690b83f..d4589ac0 100644 Binary files a/bin/app/data/gui/window/dots.png and b/bin/app/data/gui/window/dots.png differ diff --git a/bin/app/data/gui/window/dots_hover.png b/bin/app/data/gui/window/dots_hover.png index 47b52807..d161d432 100644 Binary files a/bin/app/data/gui/window/dots_hover.png and b/bin/app/data/gui/window/dots_hover.png differ diff --git a/bin/app/data/gui/window/help.png b/bin/app/data/gui/window/help.png index 92bfa678..b644bb04 100644 Binary files a/bin/app/data/gui/window/help.png and b/bin/app/data/gui/window/help.png differ diff --git a/bin/app/data/gui/window/help_hover.png b/bin/app/data/gui/window/help_hover.png index 212a0c31..9dc671dc 100644 Binary files a/bin/app/data/gui/window/help_hover.png and b/bin/app/data/gui/window/help_hover.png differ diff --git a/bin/app/data/gui/window/logo.png b/bin/app/data/gui/window/logo.png index ce630305..8e90c857 100644 Binary files a/bin/app/data/gui/window/logo.png and b/bin/app/data/gui/window/logo.png differ diff --git a/bin/app/data/gui/window/minus.png b/bin/app/data/gui/window/minus.png index 70e89a82..eecdc3b4 100644 Binary files a/bin/app/data/gui/window/minus.png and b/bin/app/data/gui/window/minus.png differ diff --git a/bin/app/data/gui/window/minus_hover.png b/bin/app/data/gui/window/minus_hover.png index 089a7144..de576289 100644 Binary files a/bin/app/data/gui/window/minus_hover.png and b/bin/app/data/gui/window/minus_hover.png differ diff --git a/bin/app/data/gui/window/plus.png b/bin/app/data/gui/window/plus.png index 743de91e..58645d26 100644 Binary files a/bin/app/data/gui/window/plus.png and b/bin/app/data/gui/window/plus.png differ diff --git a/bin/app/data/gui/window/plus_hover.png b/bin/app/data/gui/window/plus_hover.png index 67bbc8ac..63fe8c02 100644 Binary files a/bin/app/data/gui/window/plus_hover.png and b/bin/app/data/gui/window/plus_hover.png differ diff --git a/bin/app/data/gui/window/refresh.png b/bin/app/data/gui/window/refresh.png index 9a9371b4..61f4b669 100644 Binary files a/bin/app/data/gui/window/refresh.png and b/bin/app/data/gui/window/refresh.png differ diff --git a/bin/app/data/gui/window/refresh_hover.png b/bin/app/data/gui/window/refresh_hover.png index e7d5b14f..8519c38f 100644 Binary files a/bin/app/data/gui/window/refresh_hover.png and b/bin/app/data/gui/window/refresh_hover.png differ diff --git a/bin/test/data/log/test_log.txt b/bin/test/data/log/test_log.txt index c99f7782..3312f141 100644 --- a/bin/test/data/log/test_log.txt +++ b/bin/test/data/log/test_log.txt @@ -47,11 +47,3 @@ NetworkProtocolHelper.cpp ERROR: Failed to parse message, invalid type token NetworkProtocolHelper.cpp ERROR: Failed to parse setActiveToken message, invalid token count Settings.cpp WARNING: File for Settings not found: data/SettingsTestSuite/wrong_settings.xml Settings.cpp WARNING: File for Settings not found: data/SettingsTestSuite/wrong_settings.xml -TextAccess.cpp ERROR: Could not open file path/to/test.h -TextAccess.cpp WARNING: Index 'firstLine' has to be lower or equal index 'lastLine', is 3 > 2 -TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8 -TextAccess.cpp WARNING: Tried to access index 10. Maximum index is 8 -TextAccess.cpp WARNING: Line numbers start with one, is 0 -TextAccess.cpp WARNING: Line numbers start with one, is 0 -TokenLocationCollection.cpp ERROR: Can't create TokenLocation with wrong boundaries. -TokenLocationCollection.cpp ERROR: Can't create TokenLocation with wrong boundaries. diff --git a/cmake/LinuxPackage.cmake b/cmake/LinuxPackage.cmake index 6baf95e6..7cdcebb1 100644 --- a/cmake/LinuxPackage.cmake +++ b/cmake/LinuxPackage.cmake @@ -38,7 +38,6 @@ function(AddSharedToComponent componentName) DESTINATION . COMPONENT ${componentName} PATTERN "log/*" EXCLUDE - PATTERN "projects/ignored" EXCLUDE PATTERN "data/src" EXCLUDE PATTERN "data/gui/installer" EXCLUDE PATTERN "data/install" EXCLUDE @@ -83,7 +82,13 @@ function(AddSharedToComponent componentName) PATTERN "ApplicationSettings_for_package.xml" EXCLUDE PATTERN "ProjectSettings_template.xml" EXCLUDE PATTERN "ApplicationSettings_template.xml" EXCLUDE - PATTERN "window_settings.ini_for_package" EXCLUDE + PATTERN "window_settings_for_package.ini" EXCLUDE + ) + + INSTALL(FILES ${CMAKE_SOURCE_DIR}/bin/app/user/window_settings_for_package.ini + DESTINATION user + COMPONENT ${componentName} + RENAME window_settings.ini ) endfunction(AddSharedToComponent) @@ -141,32 +146,32 @@ INSTALL(PROGRAMS COMPONENT FULL ) -#INSTALL(PROGRAMS - #${CMAKE_SOURCE_DIR}/bin/app/Release/Coati_upx - #DESTINATION . - #COMPONENT FULL - #RENAME Coati -#) - -#INSTALL(PROGRAMS - #${CMAKE_SOURCE_DIR}/bin/app/Release/Coati_trial_upx - #DESTINATION . - #COMPONENT TRIAL - #RENAME Coati_trial -#) - -INSTALL(TARGETS - ${APP_PROJECT_NAME} +INSTALL(PROGRAMS + ${CMAKE_SOURCE_DIR}/bin/app/Release/Coati_upx DESTINATION . COMPONENT FULL + RENAME Coati ) -INSTALL(TARGETS - ${TRIAL_PROJECT_NAME} +INSTALL(PROGRAMS + ${CMAKE_SOURCE_DIR}/bin/app/Release/Coati_trial_upx DESTINATION . COMPONENT TRIAL + RENAME Coati_trial ) +#INSTALL(TARGETS + #${APP_PROJECT_NAME} + #DESTINATION . + #COMPONENT FULL +#) + +#INSTALL(TARGETS + #${TRIAL_PROJECT_NAME} + #DESTINATION . + #COMPONENT TRIAL +#) + # SET(CPACK_GENERATOR "DEB;TGZ") SET(CPACK_GENERATOR "TGZ") SET(CPACK_ARCHIVE_COMPONENT_INSTALL "ON") @@ -186,6 +191,7 @@ endif() SET(CPACK_PACKAGE_NAME "Coati") SET(CPACK_PACKAGING_INSTALL_PREFIX "") +SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 1) SET(CPACK_PACKAGING_INSTALL_DIRECTORY "Coati") SET(CPACK_PACKAGE_VERSION ${VERSION_NUMBER}) SET(CPACK_PACKAGE_VENDOR "Coati Software") diff --git a/cmake/add_files.cmake b/cmake/add_files.cmake index 06f272ad..50d56e20 100644 --- a/cmake/add_files.cmake +++ b/cmake/add_files.cmake @@ -11,19 +11,19 @@ # ) # macro(add_files var_name) - file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") + file (RELATIVE_PATH _relPath "${CMAKE_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}") - foreach (_src ${ARGN}) - if (_relPath) - list (APPEND ${var_name} "${_relPath}/${_src}") - else() - list (APPEND ${var_name} "${_src}") - endif() - endforeach() + foreach (_src ${ARGN}) + if (_relPath) + list (APPEND ${var_name} "${_relPath}/${_src}") + else() + list (APPEND ${var_name} "${_src}") + endif() + endforeach() - if (_relPath) - set(${var_name} ${${var_name}} PARENT_SCOPE) - else() - set(${var_name} ${${var_name}}) - endif() + if (_relPath) + set(${var_name} ${${var_name}} PARENT_SCOPE) + else() + set(${var_name} ${${var_name}}) + endif() endmacro() diff --git a/cmake/pre_install_linux.cmake b/cmake/pre_install_linux.cmake index 5d1c1217..95486773 100644 --- a/cmake/pre_install_linux.cmake +++ b/cmake/pre_install_linux.cmake @@ -1,6 +1,7 @@ # upx set(upxPath ${CMAKE_CURRENT_LIST_DIR}/../bin/app/Release) + message(STATUS "upx the app") execute_process( COMMAND rm ${upxPath}/Coati_upx @@ -13,6 +14,9 @@ execute_process( COMMAND upx --brute ${upxPath}/Coati_trial -o ${upxPath}/Coati_trial_upx ) +execute_process( + COMMAND ${upxPath}/Coati -z /home/vagrant/dev/license.txt +) execute_process( COMMAND ${upxPath}/Coati -f -d ${upxPath}/../data/projects/tictactoe/tictactoe.coatiproject diff --git a/setup/Linux/Coati.sh b/setup/Linux/Coati.sh index 0c71f39c..8962e000 100755 --- a/setup/Linux/Coati.sh +++ b/setup/Linux/Coati.sh @@ -3,21 +3,22 @@ # get the current directory SOURCE="${0}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done COATI_PATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )" #setup data folder if [ ! -d "${HOME}/.config/coati" ]; then - # Control will enter here if $DIRECTORY doesn't exist. - mkdir -p ${HOME}/.config/coati - cp $COATI_PATH/user/* ${HOME}/.config/coati/ - echo "First start of Coati from this user, copy default configfiles to ~/.config/coati" + # Control will enter here if $DIRECTORY doesn't exist. + mkdir -p ${HOME}/.config/coati + echo "First start of Coati from this user, copy default configfiles to ~/.config/coati" fi +cp -rn $COATI_PATH/user/* ${HOME}/.config/coati/ + export LD_LIBRARY_PATH="$COATI_PATH/lib:LD_LIBRARY_PATH" export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb:$QT_XKB_CONFIG_ROOT" -export QT_QPA_FONTDIR="$COATI_PATH/data/fonts:$QT_QPA_FONTDIR" +#export QT_QPA_FONTDIR="$COATI_PATH/data/fonts:$QT_QPA_FONTDIR" exec $COATI_PATH/Coati $@ diff --git a/setup/Linux/Coati_trial.sh b/setup/Linux/Coati_trial.sh index d7f6dd51..b0126dab 100755 --- a/setup/Linux/Coati_trial.sh +++ b/setup/Linux/Coati_trial.sh @@ -3,23 +3,24 @@ # get the current directory SOURCE="${0}" while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink - DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" - SOURCE="$(readlink "$SOURCE")" - [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located + DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" + SOURCE="$(readlink "$SOURCE")" + [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located done COATI_PATH="$( cd -P "$( dirname "$SOURCE" )" && pwd )" #setup data folder echo $COATI_PATH if [ ! -d "${HOME}/.config/coatitrial" ]; then - # Control will enter here if $DIRECTORY doesn't exist. - mkdir -p ${HOME}/.config/coatitrial - cp $COATI_PATH/user/* ${HOME}/.config/coatitrial/ - echo "First start of Coati from this user, copy default configfiles to ~/.config/coati" + # Control will enter here if $DIRECTORY doesn't exist. + mkdir -p ${HOME}/.config/coatitrial + echo "First start of Coati from this user, copy default configfiles to ~/.config/coati" fi +cp -nr $COATI_PATH/user/* ${HOME}/.config/coatitrial/ + export LD_LIBRARY_PATH="$COATI_PATH/lib:LD_LIBRARY_PATH" export QT_XKB_CONFIG_ROOT="/usr/share/X11/xkb:$QT_XKB_CONFIG_ROOT" -export QT_QPA_FONTDIR="$COATI_PATH/data/fonts:$QT_QPA_FONTDIR" +#export QT_QPA_FONTDIR="$COATI_PATH/data/fonts:$QT_QPA_FONTDIR" exec $COATI_PATH/Coati_trial diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 14662659..53325b86 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -252,6 +252,7 @@ add_files( utility/messaging/type/MessageScrollCode.h utility/messaging/type/MessageSearch.h utility/messaging/type/MessageSearchAutocomplete.h + utility/messaging/type/MessageSearchFullText.h utility/messaging/type/MessageShowErrors.h utility/messaging/type/MessageShowScope.h utility/messaging/type/MessageShowStartScreen.h diff --git a/src/lib/component/controller/CodeController.cpp b/src/lib/component/controller/CodeController.cpp index b1487f67..d70bf65f 100644 --- a/src/lib/component/controller/CodeController.cpp +++ b/src/lib/component/controller/CodeController.cpp @@ -238,6 +238,15 @@ void CodeController::handleMessage(MessageShowErrors* message) showContents(message); } +void CodeController::handleMessage(MessageSearchFullText* message) +{ + CodeView* view = getView(); + std::vector snippets = getSnippetsForFullTextSearch(message->searchTerm); + view->showCodeSnippets(snippets, std::vector()); + + showContents(message); +} + void CodeController::handleMessage(MessageShowScope* message) { std::shared_ptr collection = @@ -362,15 +371,25 @@ std::vector CodeController::getSnippetsForActiveTokenLocation return fileSnippets; } -std::vector CodeController::getSnippetsForFile(std::shared_ptr activeTokenLocations) const +std::vector CodeController::getSnippetsForFile( + std::shared_ptr activeTokenLocations +) const { - return getSnippetsForFile(activeTokenLocations, m_storageAccess->getTokenLocationsForFile(activeTokenLocations->getFilePath().str())); + return getSnippetsForFile( + activeTokenLocations, + m_storageAccess->getTokenLocationsForFile(activeTokenLocations->getFilePath().str()) + ); } -std::vector CodeController::getSnippetsForFile(std::shared_ptr activeTokenLocations, const std::shared_ptr fileLocations) const +std::vector CodeController::getSnippetsForFile( + std::shared_ptr activeTokenLocations, + const std::shared_ptr fileLocations +) const { + std::shared_ptr textAccess = m_storageAccess->getFileContent(activeTokenLocations->getFilePath()); - std::shared_ptr scopeLocations = std::make_shared(activeTokenLocations->getFilePath().str()); + std::shared_ptr scopeLocations + = std::make_shared(activeTokenLocations->getFilePath().str()); fileLocations->forEachStartTokenLocation( [&](TokenLocation* startLoc) -> void { @@ -423,9 +442,10 @@ std::vector CodeController::getSnippetsForFile(std::shared_pt ranges = fileScopedMerger.merge(atomicRanges); } - const int snippetExpandRange = ApplicationSettings::getInstance()->getCodeSnippetExpandRange(); std::vector snippets; + + std::shared_ptr file = m_storageAccess->getTokenLocationsForFile(activeTokenLocations->getFilePath().str()); for (const SnippetMerger::Range& range: ranges) { CodeSnippetParams params; @@ -434,8 +454,7 @@ std::vector CodeController::getSnippetsForFile(std::shared_pt params.startLineNumber = std::max(1, range.start.row - (range.start.strong ? 0 : snippetExpandRange)); params.endLineNumber = std::min(textAccess->getLineCount(), range.end.row + (range.end.strong ? 0 : snippetExpandRange)); - std::shared_ptr tempFile = - m_storageAccess->getTokenLocationsForLinesInFile(activeTokenLocations->getFilePath().str(), params.startLineNumber, params.endLineNumber); + std::shared_ptr tempFile = file->getFilteredByLines(params.startLineNumber, params.endLineNumber); TokenLocationLine* firstUsedLine = nullptr; for (size_t i = params.startLineNumber; i <= params.endLineNumber && firstUsedLine == nullptr; i++) { @@ -461,7 +480,6 @@ std::vector CodeController::getSnippetsForFile(std::shared_pt params.title = activeTokenLocations->getFilePath().str(); } - TokenLocationLine* lastUsedLine = nullptr; for (size_t i = params.endLineNumber; i >= params.startLineNumber && lastUsedLine == nullptr; i--) { @@ -495,7 +513,11 @@ std::vector CodeController::getSnippetsForFile(std::shared_pt } std::shared_ptr CodeController::buildMergerHierarchy( - TokenLocation* location, std::shared_ptr scopeLocations, SnippetMerger& fileScopedMerger, std::map>& mergers) const + TokenLocation* location, + std::shared_ptr scopeLocations, + SnippetMerger& fileScopedMerger, + std::map>& mergers +) const { const TokenLocation* currentLocation = location; std::shared_ptr currentMerger = std::make_shared( @@ -530,7 +552,10 @@ std::shared_ptr CodeController::buildMergerHierarchy( return currentMerger; } -std::shared_ptr CodeController::getTokenLocationOfParentScope(const TokenLocation* location, std::shared_ptr scopeLocations) const +std::shared_ptr CodeController::getTokenLocationOfParentScope( + const TokenLocation* location, + std::shared_ptr scopeLocations +) const { const TokenLocation* parent = location; const FilePath filePath = location->getFilePath(); @@ -545,7 +570,8 @@ std::shared_ptr CodeController::getTokenLocationOfParentScope { parent = tokenLocation; } - // since tokenLocation is a start location the > location indicates the scope that is closer to the child. + // since tokenLocation is a start location the > location indicates the scope + // that is closer to the child. else if ((*tokenLocation) > *parent) { parent = tokenLocation; @@ -563,6 +589,37 @@ std::shared_ptr CodeController::getTokenLocationOfParentScope return file; } +std::vector CodeController::getSnippetsForFullTextSearch( + const std::string& searchTerm) const +{ + std::shared_ptr collection = + m_storageAccess->getFullTextSearchLocations(searchTerm); + + std::vector snippets; + + collection->forEachTokenLocationFile( + [&](std::shared_ptr file) -> void + { + //if (snippets.size() < 10) + { + std::vector fileSnippets = getSnippetsForFile(file); + snippets.insert(snippets.end(), fileSnippets.begin(), fileSnippets.end()); + } + //else + //{ + //CodeSnippetParams params; + //params.locationFile = file; + //params.refCount = file->getUnscopedStartTokenLocationCount(); + //params.isCollapsed = true; + //snippets.push_back(params); + //} + } + ); + + addModificationTimes(snippets); + return snippets; +} + std::vector CodeController::getSnippetsForErrorLocations( std::vector* errors) const { diff --git a/src/lib/component/controller/CodeController.h b/src/lib/component/controller/CodeController.h index a77d4b62..9d99d6b3 100644 --- a/src/lib/component/controller/CodeController.h +++ b/src/lib/component/controller/CodeController.h @@ -13,6 +13,7 @@ #include "utility/messaging/type/MessageFocusIn.h" #include "utility/messaging/type/MessageFocusOut.h" #include "utility/messaging/type/MessageScrollCode.h" +#include "utility/messaging/type/MessageSearchFullText.h" #include "utility/messaging/type/MessageShowErrors.h" #include "utility/messaging/type/MessageShowScope.h" #include "utility/types.h" @@ -35,6 +36,7 @@ class CodeController , public MessageListener , public MessageListener , public MessageListener + , public MessageListener , public MessageListener , public MessageListener { @@ -53,6 +55,7 @@ private: virtual void handleMessage(MessageFocusIn* message); virtual void handleMessage(MessageFocusOut* message); virtual void handleMessage(MessageScrollCode* message); + virtual void handleMessage(MessageSearchFullText* message); virtual void handleMessage(MessageShowErrors* message); virtual void handleMessage(MessageShowScope* message); @@ -66,6 +69,7 @@ private: std::vector getSnippetsForFile( std::shared_ptr activeTokenLocations, std::shared_ptr fileLocations) const; std::vector getSnippetsForFile(std::shared_ptr file) const; + std::vector getSnippetsForFullTextSearch(const std::string& searchTerm) const; std::shared_ptr buildMergerHierarchy( TokenLocation* location, std::shared_ptr context, SnippetMerger& fileScopedMerger, std::map>& mergers) const; std::shared_ptr getTokenLocationOfParentScope(const TokenLocation* location, std::shared_ptr context) const; diff --git a/src/lib/component/controller/GraphController.cpp b/src/lib/component/controller/GraphController.cpp index bda243d3..fd44e795 100644 --- a/src/lib/component/controller/GraphController.cpp +++ b/src/lib/component/controller/GraphController.cpp @@ -87,6 +87,11 @@ void GraphController::handleMessage(MessageFlushUpdates* message) buildGraph(message); } +void GraphController::handleMessage(MessageSearchFullText* message) +{ + clear(); +} + void GraphController::handleMessage(MessageFocusIn* message) { getView()->focusTokenIds(message->tokenIds); diff --git a/src/lib/component/controller/GraphController.h b/src/lib/component/controller/GraphController.h index 9f351dfe..fd7cefc1 100644 --- a/src/lib/component/controller/GraphController.h +++ b/src/lib/component/controller/GraphController.h @@ -13,6 +13,7 @@ #include "utility/messaging/type/MessageGraphNodeBundleSplit.h" #include "utility/messaging/type/MessageGraphNodeExpand.h" #include "utility/messaging/type/MessageGraphNodeMove.h" +#include "utility/messaging/type/MessageSearchFullText.h" #include "utility/messaging/type/MessageShowErrors.h" #include "component/controller/Controller.h" @@ -36,6 +37,7 @@ class GraphController , public MessageListener , public MessageListener , public MessageListener + , public MessageListener , public MessageListener { public: @@ -51,6 +53,7 @@ private: virtual void handleMessage(MessageGraphNodeBundleSplit* message); virtual void handleMessage(MessageGraphNodeExpand* message); virtual void handleMessage(MessageGraphNodeMove* message); + virtual void handleMessage(MessageSearchFullText* message); virtual void handleMessage(MessageShowErrors* message); GraphView* getView() const; diff --git a/src/lib/component/controller/SearchController.cpp b/src/lib/component/controller/SearchController.cpp index e8fe7e1b..401d7d24 100644 --- a/src/lib/component/controller/SearchController.cpp +++ b/src/lib/component/controller/SearchController.cpp @@ -37,6 +37,13 @@ void SearchController::handleMessage(MessageSearchAutocomplete* message) getView()->setAutocompletionList(m_storageAccess->getAutocompletionMatches(message->query)); } +void SearchController::handleMessage(MessageSearchFullText* message) +{ + LOG_INFO("fulltext string: \"" + message->searchTerm + "\""); + SearchMatch match("@" + message->searchTerm); + getView()->setMatches(std::vector(1, match)); +} + void SearchController::handleMessage(MessageShowErrors* message) { SearchMatch match = SearchMatch::createCommand(SearchMatch::COMMAND_ERROR); diff --git a/src/lib/component/controller/SearchController.h b/src/lib/component/controller/SearchController.h index 2b11a7f5..e7ec49c6 100644 --- a/src/lib/component/controller/SearchController.h +++ b/src/lib/component/controller/SearchController.h @@ -7,6 +7,7 @@ #include "utility/messaging/type/MessageActivateTokens.h" #include "utility/messaging/type/MessageFind.h" #include "utility/messaging/type/MessageSearchAutocomplete.h" +#include "utility/messaging/type/MessageSearchFullText.h" #include "utility/messaging/type/MessageShowErrors.h" class StorageAccess; @@ -18,6 +19,7 @@ class SearchController , public MessageListener , public MessageListener , public MessageListener + , public MessageListener , public MessageListener { public: @@ -29,6 +31,7 @@ private: virtual void handleMessage(MessageActivateTokens* message); virtual void handleMessage(MessageFind* message); virtual void handleMessage(MessageSearchAutocomplete* message); + virtual void handleMessage(MessageSearchFullText* message); virtual void handleMessage(MessageShowErrors* message); SearchView* getView(); diff --git a/src/lib/component/controller/UndoRedoController.cpp b/src/lib/component/controller/UndoRedoController.cpp index b74ee483..804dcf78 100644 --- a/src/lib/component/controller/UndoRedoController.cpp +++ b/src/lib/component/controller/UndoRedoController.cpp @@ -219,6 +219,18 @@ void UndoRedoController::handleMessage(MessageSearch* message) processCommand(command); } +void UndoRedoController::handleMessage(MessageSearchFullText* message) +{ + if (sameMessageTypeAsLast(message))// && + //static_cast(lastMessage())->getMatchesAsString() == message->getMatchesAsString()) + { + return; + } + + Command command(std::make_shared(*message), Command::ORDER_ACTIVATE); + processCommand(command); +} + void UndoRedoController::handleMessage(MessageShowScope* message) { Command command(std::make_shared(*message), Command::ORDER_ADAPT); diff --git a/src/lib/component/controller/UndoRedoController.h b/src/lib/component/controller/UndoRedoController.h index b97cdaa1..674952ad 100644 --- a/src/lib/component/controller/UndoRedoController.h +++ b/src/lib/component/controller/UndoRedoController.h @@ -20,6 +20,7 @@ #include "utility/messaging/type/MessageRefresh.h" #include "utility/messaging/type/MessageScrollCode.h" #include "utility/messaging/type/MessageSearch.h" +#include "utility/messaging/type/MessageSearchFullText.h" #include "utility/messaging/type/MessageShowScope.h" #include "utility/messaging/type/MessageUndo.h" @@ -46,6 +47,7 @@ class UndoRedoController , public MessageListener , public MessageListener , public MessageListener + , public MessageListener , public MessageListener , public MessageListener { @@ -86,6 +88,7 @@ private: virtual void handleMessage(MessageRefresh* message); virtual void handleMessage(MessageScrollCode* message); virtual void handleMessage(MessageSearch* message); + virtual void handleMessage(MessageSearchFullText* message); virtual void handleMessage(MessageShowScope* message); virtual void handleMessage(MessageUndo* message); diff --git a/src/lib/data/SqliteStorage.cpp b/src/lib/data/SqliteStorage.cpp index 6579c2ce..ea8190b4 100644 --- a/src/lib/data/SqliteStorage.cpp +++ b/src/lib/data/SqliteStorage.cpp @@ -3,6 +3,7 @@ #include "data/graph/Node.h" #include "data/location/TokenLocation.h" #include "data/DefinitionType.h" +#include "data/parser/ParseLocation.h" #include "data/SqliteIndex.h" #include "utility/logging/logging.h" #include "utility/text/TextAccess.h" @@ -207,7 +208,8 @@ Id SqliteStorage::addError(const std::string& message, bool fatal, const std::st m_database.execDML(( "INSERT INTO error(message, fatal, file_path, line_number, column_number) " - "VALUES ('" + sanitizedMessage + "', " + std::to_string(fatal) + ", '" + filePath + "', " + std::to_string(lineNumber) + ", " + std::to_string(columnNumber) + ");" + "VALUES ('" + sanitizedMessage + "', " + std::to_string(fatal) + ", '" + filePath + + "', " + std::to_string(lineNumber) + ", " + std::to_string(columnNumber) + ");" ).c_str()); return m_database.lastRowId(); @@ -416,6 +418,92 @@ std::vector SqliteStorage::getEdgesByTargetType(Id targetId, int ty return edges; } +void SqliteStorage::optimizeFTSTable() const +{ + try + { + CppSQLite3Query q = m_database.execQuery("INSERT INTO file(file) VALUES('optimize');"); + } + catch(CppSQLite3Exception e) + { + LOG_ERROR(e.errorMessage()); + } +} + +std::vector SqliteStorage::getFullTextSearch(const std::string& searchTerm) const +{ + std::vector matches; + try + { + CppSQLite3Query q = m_database.execQuery(( + "SELECT id,offsets(file) FROM file WHERE content MATCH '\"*" + searchTerm + "*\"'" + ).c_str()); + + while(!q.eof()) + { + const Id fileId = q.getIntField(0,0); + + // convert the string "0 2 0 2" to int vector + std::stringstream temp_results(q.getStringField(1,0)); + std::vector results((std::istream_iterator(temp_results)),std::istream_iterator()); + + ParseLocation location; + location.filePath = getFileById(fileId).filePath; + std::shared_ptr file = getFileContentByPath(location.filePath.str()); + + int charsInPreviousLines = 0; + int lineNumber = 1; + std::string line; + // results + // i ... col + // i+1 ... term + // i+2 ... offset + // i+3 ... length + line = file->getLine(lineNumber); + for (size_t i = 0; i < results.size() ; i+=4) + { + while( ((charsInPreviousLines + (int)line.length()) < results[i+2]) && results[i+1] == 0 ) + { + lineNumber++; + charsInPreviousLines += line.length(); + line = file->getLine(lineNumber); + } + + //only set start if its the first term of the match + if ( results[i+1] == 0 ) + { + location.startLineNumber = lineNumber; + // +1 to be consistent with the rest of the codebase + location.startColumnNumber = results[i+2] - charsInPreviousLines + 1; + } + + while( (charsInPreviousLines + (int)line.length()) < (results[i+2] + results[i+3]) ) + { + lineNumber++; + charsInPreviousLines += line.length(); + line = file->getLine(lineNumber); + } + + location.endLineNumber = lineNumber; + location.endColumnNumber = results[i+2] + results[i+3] - charsInPreviousLines; + + // add match if the next term is the first term of a match or its the last term in the file + if ( (i+4 < results.size() && results[i+5] == 0) || i+4 >= results.size() ) + { + matches.push_back(location); + } + } + + q.nextRow(); + } + } + catch(CppSQLite3Exception e) + { + LOG_ERROR(e.errorMessage()); + } + return matches; +} + StorageNode SqliteStorage::getNodeById(Id id) const { if (id != 0) @@ -475,6 +563,23 @@ std::vector SqliteStorage::getAllFiles() const return getAllFiles(""); } +std::vector SqliteStorage::getAllFileIds() const +{ + std::vector ids; + + CppSQLite3Query q = m_database.execQuery( + "SELECT id FROM file;" + ); + + while (!q.eof()) + { + ids.push_back(q.getIntField(0,0)); + q.nextRow(); + } + + return ids; +} + std::shared_ptr SqliteStorage::getFileContentByPath(const std::string& filePath) const { CppSQLite3Query q = m_database.execQuery(( @@ -786,16 +891,24 @@ void SqliteStorage::setupTables() "CREATE INDEX IF NOT EXISTS node_serialized_name_index ON node(serialized_name);" ); - m_database.execDML( - "CREATE TABLE IF NOT EXISTS file(" - "id INTEGER NOT NULL, " - "path TEXT, " - "modification_time TEXT, " - "content TEXT, " - "loc INTEGER, " - "PRIMARY KEY(id), " - "FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE);" - ); + try + { + m_database.execDML( + "CREATE VIRTUAL TABLE IF NOT EXISTS file USING fts4(" + //"CREATE TABLE IF NOT EXISTS file (" + "id INTEGER NOT NULL, " + "path TEXT, " + "modification_time TEXT, " + "content TEXT, " + "loc INTEGER, " + "PRIMARY KEY(id), " + "FOREIGN KEY(id) REFERENCES node(id) ON DELETE CASCADE);" + ); + } + catch (CppSQLite3Exception& e) + { + std::cerr << e.errorCode() << ":" << e.errorMessage() << std::endl; + } m_database.execDML( "CREATE TABLE IF NOT EXISTS local_symbol(" diff --git a/src/lib/data/SqliteStorage.h b/src/lib/data/SqliteStorage.h index 29abf92f..2bab8b5a 100644 --- a/src/lib/data/SqliteStorage.h +++ b/src/lib/data/SqliteStorage.h @@ -9,13 +9,14 @@ #include "utility/file/FilePath.h" #include "utility/types.h" -#include "data/name/NameHierarchy.h" #include "data/location/TokenLocationFile.h" #include "data/location/TokenLocationCollection.h" +#include "data/name/NameHierarchy.h" #include "data/StorageTypes.h" class TextAccess; class Version; +struct ParseLocation; class SqliteStorage { @@ -83,6 +84,7 @@ public: StorageFile getFileById(const Id id) const; StorageFile getFileByPath(const FilePath& filePath) const; + std::vector getAllFileIds() const; std::vector getFilesByPaths(const std::vector& filePaths) const; std::vector getAllFiles() const; std::shared_ptr getFileContentByPath(const std::string& filePath) const; @@ -100,6 +102,9 @@ public: StorageComponentAccess getComponentAccessByMemberEdgeId(Id memberEdgeId) const; std::vector getComponentAccessByMemberEdgeIds(const std::vector& memberEdgeIds) const; + std::vector getFullTextSearch(const std::string& searchTerm) const; + void optimizeFTSTable() const; + std::vector getCommentLocationsInFile(const FilePath& filePath) const; std::vector getAllErrors() const; std::vector getFatalErrors() const; diff --git a/src/lib/data/Storage.cpp b/src/lib/data/Storage.cpp index 121087b4..25cbe942 100644 --- a/src/lib/data/Storage.cpp +++ b/src/lib/data/Storage.cpp @@ -172,6 +172,7 @@ void Storage::finishParsing() { buildSearchIndex(); buildHierarchyCache(); + optimizeFTSTable(); } void Storage::injectData(std::shared_ptr injectedStorage) @@ -217,6 +218,29 @@ Node::NodeType Storage::getNodeTypeForNodeWithId(Id nodeId) const return Node::intToType(m_sqliteStorage.getNodeById(nodeId).type); } +std::shared_ptr Storage::getFullTextSearchLocations(const std::string& searchTerm) const +{ + std::shared_ptr collection = std::make_shared(); + + std::vector parseLocations = m_sqliteStorage.getFullTextSearch(searchTerm); + size_t i = 0; + for(ParseLocation location : parseLocations) + { + collection->addTokenLocation( + i, + 0, + location.filePath, + location.startLineNumber, + location.startColumnNumber, + location.endLineNumber, + location.endColumnNumber + )->setType(LOCATION_FULLTEXTSEARCH_MATCH); + i++; + } + + return collection; +} + std::vector Storage::getAutocompletionMatches(const std::string& query) const { std::vector commandResults = m_commandIndex.search(query, 0); @@ -316,7 +340,8 @@ std::vector Storage::getAutocompletionMatches(const std::string& qu match.nodeType = Node::intToType(firstNode->type); match.typeName = Node::getTypeString(match.nodeType); - if (intToDefinitionType(firstNode->definitionType) == DEFINITION_NONE && match.nodeType != Node::NODE_UNDEFINED) + if (intToDefinitionType(firstNode->definitionType) == DEFINITION_NONE + && match.nodeType != Node::NODE_UNDEFINED) { match.typeName = "undefined " + match.typeName; } @@ -401,6 +426,7 @@ std::shared_ptr Storage::getGraphForActiveTokenIds(const std::vector& std::vector edgeIds; bool addAggregations = false; + //m_sqliteStorage.getFullTextSearch("const int"); if (tokenIds.size() == 1) { const Id elementId = tokenIds[0]; @@ -575,7 +601,9 @@ std::vector Storage::getTokenIdsForMatches(const std::vector& m { for (size_t i = 0; i < match.nameHierarchies.size(); i++) { - idSet.insert(m_sqliteStorage.getNodeBySerializedName(NameHierarchy::serialize(match.nameHierarchies[i])).id); + idSet.insert( + m_sqliteStorage.getNodeBySerializedName(NameHierarchy::serialize(match.nameHierarchies[i])).id + ); } } @@ -638,9 +666,10 @@ std::shared_ptr Storage::getTokenLocationsForTokenIds(c std::vector fileIds; std::vector nonFileIds; + std::vector allFileIds = m_sqliteStorage.getAllFileIds(); for (size_t i = 0; i < tokenIds.size(); i++) { - if (m_sqliteStorage.isFile(tokenIds[i])) + if (std::find(allFileIds.begin(), allFileIds.end(),tokenIds[i]) != allFileIds.end()) { fileIds.push_back(tokenIds[i]); } @@ -653,7 +682,9 @@ std::shared_ptr Storage::getTokenLocationsForTokenIds(c for (Id fileId: fileIds) { StorageFile storageFile = m_sqliteStorage.getFileById(fileId); - collection->addTokenLocationFileAsPlainCopy(m_sqliteStorage.getTokenLocationsForFile(storageFile.filePath).get()); + collection->addTokenLocationFileAsPlainCopy( + m_sqliteStorage.getTokenLocationsForFile(storageFile.filePath).get() + ); } Cache filePathCache( @@ -688,7 +719,9 @@ std::shared_ptr Storage::getTokenLocationsForTokenIds(c return collection; } -std::shared_ptr Storage::getTokenLocationsForLocationIds(const std::vector& locationIds) const +std::shared_ptr Storage::getTokenLocationsForLocationIds( + const std::vector& locationIds +) const { std::shared_ptr collection = std::make_shared(); @@ -925,7 +958,11 @@ void Storage::addEdgesToGraph(const std::vector& edgeIds, Graph* graph) cons } } -void Storage::addNodesWithChildrenAndEdgesToGraph(const std::vector& nodeIds, const std::vector& edgeIds, Graph* graph) const +void Storage::addNodesWithChildrenAndEdgesToGraph( + const std::vector& nodeIds, + const std::vector& edgeIds, + Graph* graph +) const { std::set parentNodeIds; @@ -1099,3 +1136,8 @@ void Storage::buildHierarchyCache() m_hierarchyCache.createConnection(edge.id, edge.sourceNodeId, edge.targetNodeId, isVisible); } } + +void Storage::optimizeFTSTable() +{ + m_sqliteStorage.optimizeFTSTable(); +} diff --git a/src/lib/data/Storage.h b/src/lib/data/Storage.h index fbcf958b..45ecf74b 100644 --- a/src/lib/data/Storage.h +++ b/src/lib/data/Storage.h @@ -10,6 +10,7 @@ #include "data/graph/token_component/TokenComponentAccess.h" #include "data/location/TokenLocationCollection.h" #include "data/parser/ParserClient.h" +#include "data/parser/ParseLocation.h" #include "data/search/SearchIndex.h" #include "data/HierarchyCache.h" #include "data/SqliteStorage.h" @@ -54,6 +55,7 @@ public: virtual NameHierarchy getNameHierarchyForNodeWithId(Id nodeId) const; virtual Node::NodeType getNodeTypeForNodeWithId(Id nodeId) const; + virtual std::shared_ptr getFullTextSearchLocations(const std::string& searchTerm) const; virtual std::vector getAutocompletionMatches(const std::string& query) const; virtual std::vector getSearchMatchesForTokenIds(const std::vector& elementIds) const; @@ -69,8 +71,12 @@ public: virtual Id getTokenIdForFileNode(const FilePath& filePath) const; virtual std::vector getTokenIdsForAggregationEdge(Id sourceId, Id targetId) const; - virtual std::shared_ptr getTokenLocationsForTokenIds(const std::vector& tokenIds) const; - virtual std::shared_ptr getTokenLocationsForLocationIds(const std::vector& locationIds) const; + virtual std::shared_ptr getTokenLocationsForTokenIds( + const std::vector& tokenIds + ) const; + virtual std::shared_ptr getTokenLocationsForLocationIds( + const std::vector& locationIds + ) const; virtual std::shared_ptr getTokenLocationsForFile(const std::string& filePath) const; virtual std::shared_ptr getTokenLocationsForLinesInFile( const std::string& filePath, uint firstLineNumber, uint lastLineNumber @@ -96,13 +102,17 @@ private: void addNodesToGraph(const std::vector& nodeIds, Graph* graph) const; void addEdgesToGraph(const std::vector& edgeIds, Graph* graph) const; - void addNodesWithChildrenAndEdgesToGraph(const std::vector& nodeIds, const std::vector& edgeIds, Graph* graph) const; + void addNodesWithChildrenAndEdgesToGraph( + const std::vector& nodeIds, + const std::vector& edgeIds, Graph* graph + ) const; void addAggregationEdgesToGraph(const Id nodeId, Graph* graph) const; void addComponentAccessToGraph(Graph* graph) const; void buildSearchIndex(); void buildHierarchyCache(); + void optimizeFTSTable(); void log(std::string type, std::string str, const ParseLocation& location) const; diff --git a/src/lib/data/access/StorageAccess.h b/src/lib/data/access/StorageAccess.h index 663895dd..03803bc0 100644 --- a/src/lib/data/access/StorageAccess.h +++ b/src/lib/data/access/StorageAccess.h @@ -9,6 +9,7 @@ #include "utility/file/FileInfo.h" #include "utility/file/FilePath.h" +#include "data/parser/ParseLocation.h" #include "data/graph/Node.h" #include "data/search/SearchMatch.h" #include "data/ErrorCountInfo.h" @@ -36,6 +37,8 @@ public: virtual NameHierarchy getNameHierarchyForNodeWithId(Id id) const = 0; virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const = 0; + virtual std::shared_ptr getFullTextSearchLocations( + const std::string& searchTerm) const = 0; virtual std::vector getAutocompletionMatches(const std::string& query) const = 0; virtual std::vector getSearchMatchesForTokenIds(const std::vector& tokenIds) const = 0; @@ -51,8 +54,10 @@ public: virtual Id getTokenIdForFileNode(const FilePath& filePath) const = 0; virtual std::vector getTokenIdsForAggregationEdge(Id sourceId, Id targetId) const = 0; - virtual std::shared_ptr getTokenLocationsForTokenIds(const std::vector& tokenIds) const = 0; - virtual std::shared_ptr getTokenLocationsForLocationIds(const std::vector& locationIds) const = 0; + virtual std::shared_ptr getTokenLocationsForTokenIds( + const std::vector& tokenIds) const = 0; + virtual std::shared_ptr getTokenLocationsForLocationIds( + const std::vector& locationIds) const = 0; virtual std::shared_ptr getTokenLocationsForFile(const std::string& filePath) const = 0; virtual std::shared_ptr getTokenLocationsForLinesInFile( const std::string& filePath, uint firstLineNumber, uint lastLineNumber) const = 0; diff --git a/src/lib/data/access/StorageAccessProxy.cpp b/src/lib/data/access/StorageAccessProxy.cpp index 96ac41ae..38e7b913 100644 --- a/src/lib/data/access/StorageAccessProxy.cpp +++ b/src/lib/data/access/StorageAccessProxy.cpp @@ -93,6 +93,17 @@ std::vector StorageAccessProxy::getAutocompletionMatches(const std: return std::vector(); } +std::shared_ptr StorageAccessProxy::getFullTextSearchLocations( + const std::string &searchTerm) const +{ + if (hasSubject()) + { + return m_subject->getFullTextSearchLocations(searchTerm); + } + + return std::make_shared(); +} + std::vector StorageAccessProxy::getSearchMatchesForTokenIds(const std::vector& tokenIds) const { if (hasSubject()) @@ -183,7 +194,8 @@ std::vector StorageAccessProxy::getTokenIdsForAggregationEdge(Id sourceId, I return std::vector(); } -std::shared_ptr StorageAccessProxy::getTokenLocationsForTokenIds(const std::vector& tokenIds) const +std::shared_ptr StorageAccessProxy::getTokenLocationsForTokenIds( + const std::vector& tokenIds) const { if (hasSubject()) { @@ -193,7 +205,8 @@ std::shared_ptr StorageAccessProxy::getTokenLocationsFo return std::make_shared(); } -std::shared_ptr StorageAccessProxy::getTokenLocationsForLocationIds(const std::vector& locationIds) const +std::shared_ptr StorageAccessProxy::getTokenLocationsForLocationIds( + const std::vector& locationIds) const { if (hasSubject()) { diff --git a/src/lib/data/access/StorageAccessProxy.h b/src/lib/data/access/StorageAccessProxy.h index cdb13044..53c5d590 100644 --- a/src/lib/data/access/StorageAccessProxy.h +++ b/src/lib/data/access/StorageAccessProxy.h @@ -22,6 +22,7 @@ public: virtual NameHierarchy getNameHierarchyForNodeWithId(Id id) const; virtual Node::NodeType getNodeTypeForNodeWithId(Id id) const; + virtual std::shared_ptr getFullTextSearchLocations(const std::string& searchTerm) const; virtual std::vector getAutocompletionMatches(const std::string& query) const; virtual std::vector getSearchMatchesForTokenIds(const std::vector& tokenIds) const; @@ -37,8 +38,12 @@ public: virtual Id getTokenIdForFileNode(const FilePath& filePath) const; virtual std::vector getTokenIdsForAggregationEdge(Id sourceId, Id targetId) const; - virtual std::shared_ptr getTokenLocationsForTokenIds(const std::vector& tokenIds) const; - virtual std::shared_ptr getTokenLocationsForLocationIds(const std::vector& locationIds) const; + virtual std::shared_ptr getTokenLocationsForTokenIds( + const std::vector& tokenIds + ) const; + virtual std::shared_ptr getTokenLocationsForLocationIds( + const std::vector& locationIds + ) const; virtual std::shared_ptr getTokenLocationsForFile(const std::string& filePath) const; virtual std::shared_ptr getTokenLocationsForLinesInFile( const std::string& filePath, uint firstLineNumber, uint lastLineNumber diff --git a/src/lib/data/location/LocationType.cpp b/src/lib/data/location/LocationType.cpp index 774cc67e..64c983ac 100644 --- a/src/lib/data/location/LocationType.cpp +++ b/src/lib/data/location/LocationType.cpp @@ -10,6 +10,8 @@ int locationTypeToInt(LocationType type) return 1; case LOCATION_LOCAL_SYMBOL: return 2; + case LOCATION_FULLTEXTSEARCH_MATCH: + return 3; } } @@ -23,6 +25,8 @@ LocationType intToLocationType(int value) return LOCATION_SCOPE; case 2: return LOCATION_LOCAL_SYMBOL; + case 3: + return LOCATION_FULLTEXTSEARCH_MATCH; } return LOCATION_TOKEN; } diff --git a/src/lib/data/location/LocationType.h b/src/lib/data/location/LocationType.h index e450f1b7..09b8fdcf 100644 --- a/src/lib/data/location/LocationType.h +++ b/src/lib/data/location/LocationType.h @@ -5,7 +5,8 @@ enum LocationType { LOCATION_TOKEN, LOCATION_SCOPE, - LOCATION_LOCAL_SYMBOL + LOCATION_LOCAL_SYMBOL, + LOCATION_FULLTEXTSEARCH_MATCH }; int locationTypeToInt(LocationType type); diff --git a/src/lib/data/location/TokenLocation.cpp b/src/lib/data/location/TokenLocation.cpp index 5574b25a..26b7499a 100644 --- a/src/lib/data/location/TokenLocation.cpp +++ b/src/lib/data/location/TokenLocation.cpp @@ -182,6 +182,11 @@ bool TokenLocation::isScopeTokenLocation() const return m_type == LOCATION_SCOPE; } +bool TokenLocation::isFullTextSearchMatch() const +{ + return m_type == LOCATION_FULLTEXTSEARCH_MATCH; +} + std::ostream& operator<<(std::ostream& ostream, const TokenLocation& location) { if ((&location)->isStartTokenLocation()) diff --git a/src/lib/data/location/TokenLocation.h b/src/lib/data/location/TokenLocation.h index f198567b..9e7751f3 100644 --- a/src/lib/data/location/TokenLocation.h +++ b/src/lib/data/location/TokenLocation.h @@ -50,6 +50,7 @@ public: bool isEndTokenLocation() const; bool isScopeTokenLocation() const; + bool isFullTextSearchMatch() const; private: const Id m_id; // own id diff --git a/src/lib/utility/messaging/type/MessageSearchFullText.h b/src/lib/utility/messaging/type/MessageSearchFullText.h new file mode 100644 index 00000000..695472ce --- /dev/null +++ b/src/lib/utility/messaging/type/MessageSearchFullText.h @@ -0,0 +1,28 @@ +#ifndef MESSAGE_SEARCH_FULLTEXT_H +#define MESSAGE_SEARCH_FULLTEXT_H + +#include "utility/messaging/Message.h" +#include "utility/types.h" + +class MessageSearchFullText: public Message +{ +public: + MessageSearchFullText(const std::string& searchTerm) + : searchTerm(searchTerm) + { + } + + static const std::string getStaticType() + { + return "MessageSearchFullText"; + } + + virtual void print(std::ostream& os) const + { + os << searchTerm; + } + + const std::string searchTerm; +}; + +#endif // MESSAGE_SEARCH_FULLTEXT_H diff --git a/src/lib_gui/qt/element/QtCodeArea.cpp b/src/lib_gui/qt/element/QtCodeArea.cpp index f81c1fae..343d582e 100644 --- a/src/lib_gui/qt/element/QtCodeArea.cpp +++ b/src/lib_gui/qt/element/QtCodeArea.cpp @@ -907,16 +907,9 @@ const QtCodeArea::AnnotationColor& QtCodeArea::getAnnotationColorForAnnotation(c if (!s_annotationColors.size()) { ColorScheme* scheme = ColorScheme::getInstance().get(); - std::vector types; - types.push_back("token"); - types.push_back("local_symbol"); - types.push_back("scope"); - types.push_back("error"); + std::vector types = { "token", "local_symbol", "scope", "error", "fulltextmatch"}; - std::vector states; - states.push_back("normal"); - states.push_back("focus"); - states.push_back("active"); + std::vector states = { "normal", "focus", "active"}; for (const std::string& type : types) { @@ -945,6 +938,10 @@ const QtCodeArea::AnnotationColor& QtCodeArea::getAnnotationColorForAnnotation(c { i = 9; } + else if (annotation.locationType == LOCATION_FULLTEXTSEARCH_MATCH) + { + i = 12; + } if (annotation.isActive) { diff --git a/src/lib_gui/qt/element/QtSmartSearchBox.cpp b/src/lib_gui/qt/element/QtSmartSearchBox.cpp index 02946ce1..3aad0af9 100644 --- a/src/lib_gui/qt/element/QtSmartSearchBox.cpp +++ b/src/lib_gui/qt/element/QtSmartSearchBox.cpp @@ -8,6 +8,7 @@ #include "utility/logging/logging.h" #include "utility/messaging/type/MessageSearch.h" +#include "utility/messaging/type/MessageSearchFullText.h" #include "utility/messaging/type/MessageSearchAutocomplete.h" #include "utility/text/TextAccess.h" #include "utility/utility.h" @@ -30,6 +31,11 @@ void QtSearchElement::onChecked(bool) emit wasChecked(this); } +void QtSmartSearchBox::fullTextSearch() +{ + LOG_INFO_STREAM(<< "FullTextsearch: " << text().toStdString().substr(1)); + MessageSearchFullText(text().toStdString().substr(1)).dispatch(); +} void QtSmartSearchBox::search() { @@ -144,6 +150,11 @@ void QtSmartSearchBox::keyPressEvent(QKeyEvent* event) if (event->key() == Qt::Key_Return) { + if (text().startsWith('@')) + { + fullTextSearch(); + return; + } if (!completer()->popup()->isVisible()) { search(); diff --git a/src/lib_gui/qt/element/QtSmartSearchBox.h b/src/lib_gui/qt/element/QtSmartSearchBox.h index dd954bcc..d5eb1013 100644 --- a/src/lib_gui/qt/element/QtSmartSearchBox.h +++ b/src/lib_gui/qt/element/QtSmartSearchBox.h @@ -32,6 +32,7 @@ class QtSmartSearchBox public slots: void search(); + void fullTextSearch(); public: QtSmartSearchBox(QWidget* parent);