Exclude build directory from locator results



  • Hello,
    I am using Qt Creator 4.6.0 to compile CMake project. The build directory keeps appearing in my searches and makes it very annoying.

    How to exclude build directory from:

    1. Method locator results (Ctrl+K , m )
    2. Usages results (Ctrl+Shift+U)
    3. Go to definition results (F2)

    Thank you in advance.



  • I solved this by going to Options > Environment > Locater, and unchecking "All Included C/C++ Files".
    All source files are still searchable with the "Files in any project" filter, so make sure that's on by default.



  • @plonq
    Thank you for your help.
    In combination with custom "Generic Directory Filter" included by default I've managed to filter out the build directory. This solved problem with file locator (Ctrl+K)
    But still the method locator jumps and searches files that are in build the directory. (F2, Ctrl-k,m and Ctrl+Shift+U)


  • Qt Champions 2017

    @hegemon there's no way to change this by any configuration.

    as these methods are in generated files and needed for compilation, I don't see why they should not appear in this list. you can't edit them, but they are still needed for the build.



  • @aha_1980
    Specifically I have custom files (*.q) with embedded SQL queries and custom precompiler that converts them to *.c files.
    Those C files are byproduct of our compilation process that programmer don't need to see and they are stored in build directory. When I press F2 it jumps to C file in the build directory instead of Q file that I need to edit.
    Is there any way to request a feature of filter in the locator. Even same option like in Generic Directory Filer

    0_1530701135718_gdf.JPG 0_1530701244015_m.JPG


  • Moderators

    @hegemon said in Exclude build directory from locator results:

    that programmer don't need to see and they are stored in build directory

    Personally I like the possibility to see the content (or go to variable/function definition/...) of autogenerated files - because you often need to know what was generated to understand how it works or what enum values are available, or ...
    So, I don't see a need to exclude anything.



  • @jsulm This is nice to see once in a while the output of precompiler for see what is done there, but in 99% of the cases the accidential jumps to those files are very annoying.
    Because if you don't pay attention to what kind of file you jumped, you write code and in best case you see that it is a wrong file but in the worst case you compile and all your new shiny code just disapear.


  • Qt Champions 2017

    Hi @hegemon

    I don't think this will work out of the box.

    E.g. the Qt designer files *.ui are also invisible for the code model - understandable because they are no code. Instead, the generated ui_*.h file is visible there and this one is what the compiler sees.

    If I understand you correctly, you have a simular setup and want to jump into the source *.q file.

    Now my questions:

    • is this source file directly compileable?
    • is this source file included as source in Creators project files list?

    regards



  • @aha_1980

    If I understand you correctly, you have a simular setup and want to jump into the source *.q file.

    Yes I want to jump directly to the *.q file. And it looks like *.ui file problem you've described.

    is this source file directly compileable?

    Q files can't be compiled directly by the C compiler.
    They have embedded sql with custom syntax and custom precompiler converts SQL to function calls in C file.
    For example:

    file.q:

    int par;
    EXEC SQL SELECT COL1 INTO :par FROM TABLE;
    

    converted into file_q.c:

    int par;
    run_sql_code_natively("SELECT COL1 INTO :par FROM TABLE;", &par);
    

    is this source file included as source in Creators project files list?

    Yes the *.q files are included in project files list so we can work on them directly from project.
    They are searchable and sometimes even F2 jumps right into it. But in 50% - 60% of the F2 jumps hits *.c file instead.
    Also usages shows both files.


  • Qt Champions 2017

    hi @hegemon,

    last question: how are your .q files included in the .pro file? are they in the SOURCES section?

    I think your question can be better answered at the QtCreator mailing list which is monitored by the developers. It is a good one anyway :)

    regards



  • @aha_1980 said in Exclude build directory from locator results:

    file? are they in the SOURCES section?

    I don't have *.pro file it's a CMake project.

    For example:

    # mylib.dll
    set(mylibQfiles ${CMAKE_CURRENT_SOURCE_DIR}/mycfile.q)
    preprocess_q(mylibQfilesO ${mylibQfiles})
    add_library(mylib SHARED ${mylibQfiles} ${mylibQfilesO})
    

    the preprocess_q definition is like this:

    function(preprocess_q out_var)
       set(result)
       foreach(in_f ${ARGN})
            get_filename_component(out_f ${in_f} NAME)
            set(out_f "${CMAKE_CURRENT_BINARY_DIR}/${out_f}")
            add_custom_command(OUTPUT ${out_f}_.c
                DEPENDS ${in_f}
                COMMAND ${CMAKE_SOURCE_DIR}/sqlbin/qc.exe "" -out ${out_f}_.c ${in_f}
                #      WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
                COMMENT "Creating preprocessed qc file ${in_f}"
                VERBATIM
                )
            list(APPEND result ${out_f}_.c)
       endforeach()
       set(${out_var} "${result}" PARENT_SCOPE)
    endfunction()
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.