Bug 287492 - Qt includes are not offered in #include <QFoo> form
Summary: Qt includes are not offered in #include <QFoo> form
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Language Support: CPP (old) (show other bugs)
Version: git master
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: 4.6.1
Assignee: kdevelop-bugs-null
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2011-11-24 20:51 UTC by András Manţia
Modified: 2014-01-31 13:36 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description András Manţia 2011-11-24 20:51:48 UTC
With master every time I invoke autocompletion for a (not yet included) QFoo class, it offer to include "qfoo.h", but doesn't offer <QFoo> . This used to work some time ago.
Comment 1 Milian Wolff 2011-11-26 00:19:28 UTC
can you provide a small project that triggers this behavior? it works fine for me :-/
Comment 2 András Manţia 2011-11-26 21:20:02 UTC
I can reproduce by creating a new project from inside KDevelop:
KDE->Graphical->Cmake-Qt-C++ project, remove the #include statements for QLabel, etc. and then try to add them back using the autocompletion.
Some extra information from my system:
- i have a self compiled Qt (and the system Qt as well, of course)
- system Qt is in /usr
- self compiled is in /data/development/sources/qt
- Qt is compiled in-source (so no need to install it)
- I have a symlink from /opt/qt4 to /data/development/sources/qt
- QTDIR=/opt/qt4
- compiling the test project gives this output:

/usr/bin/c++    -g -I/data/development/sources/qt/include/QtDesigner -I/data/development/sources/qt/include/QtDeclarative -I/data/development/sources/qt/include/QtScriptTools -I/data/development/sources/qt/include/QtDBus -I/data/development/sources/qt/include/QtXml -I/data/development/sources/qt/include/QtSql -I/data/development/sources/qt/include/QtOpenGL -I/data/development/sources/qt/include/QtMultimedia -I/data/development/sources/qt/include/QtNetwork -I/data/development/sources/qt/include/phonon -I/data/development/sources/qt/include/QtXmlPatterns -I/data/development/sources/qt/include/QtWebKit -I/data/development/sources/qt/include/QtHelp -I/data/development/sources/qt/include/QtUiTools -I/data/development/sources/qt/include/QtTest -I/data/development/sources/qt/include/QtScript -I/data/development/sources/qt/include/QtSvg -I/data/development/sources/qt/include/Qt3Support -I/data/development/sources/qt/include/QtGui -I/data/development/sources/qt/include/QtCore -I/data/development/sources/qt/mkspecs/default -I/data/development/sources/qt/include -I/encrypted/home/andris/projects/a/build    -o CMakeFiles/a.dir/a.cpp.o -c /encrypted/home/andris/projects/a/a.cpp

(so paths are fine)

/usr/bin/c++    -g -I/data/development/sources/qt/include/QtDesigner -I/data/development/sources/qt/include/QtDeclarative -I/data/development/sources/qt/include/QtScriptTools -I/data/development/sources/qt/include/QtDBus -I/data/development/sources/qt/include/QtXml -I/data/development/sources/qt/include/QtSql -I/data/development/sources/qt/include/QtOpenGL -I/data/development/sources/qt/include/QtMultimedia -I/data/development/sources/qt/include/QtNetwork -I/data/development/sources/qt/include/phonon -I/data/development/sources/qt/include/QtXmlPatterns -I/data/development/sources/qt/include/QtWebKit -I/data/development/sources/qt/include/QtHelp -I/data/development/sources/qt/include/QtUiTools -I/data/development/sources/qt/include/QtTest -I/data/development/sources/qt/include/QtScript -I/data/development/sources/qt/include/QtSvg -I/data/development/sources/qt/include/Qt3Support -I/data/development/sources/qt/include/QtGui -I/data/development/sources/qt/include/QtCore -I/data/development/sources/qt/mkspecs/default -I/data/development/sources/qt/include -I/encrypted/home/andris/projects/a/build    -o CMakeFiles/a.dir/a.cpp.o -c /encrypted/home/andris/projects/a/a.cpp

Generated CMakeLists.txt:
roject(a)                                                                                                                                                                                
cmake_minimum_required(VERSION 2.6)                                                                                                                                                       
find_package(Qt4 REQUIRED)                                                                                                                                                                
                                                                                                                                                                                          
include_directories(${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})                                                                                                                           
                                                                                                                                                                                          
set(a_SRCS a.cpp main.cpp)                                                                                                                                                                
qt4_automoc(${a_SRCS})                                                                                                                                                                    
add_executable(a ${a_SRCS})                                                                                                                                                               
target_link_libraries(a ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
Comment 3 András Manţia 2011-11-26 21:21:29 UTC
qmake -query
QT_INSTALL_PREFIX:/data/development/sources/qt
QT_INSTALL_DATA:/data/development/sources/qt
QT_INSTALL_DOCS:/data/development/sources/qt/doc
QT_INSTALL_HEADERS:/data/development/sources/qt/include
QT_INSTALL_LIBS:/data/development/sources/qt/lib
QT_INSTALL_BINS:/data/development/sources/qt/bin
QT_INSTALL_PLUGINS:/data/development/sources/qt/plugins
QT_INSTALL_IMPORTS:/data/development/sources/qt/imports
QT_INSTALL_TRANSLATIONS:/data/development/sources/qt/translations
QT_INSTALL_CONFIGURATION:/etc/xdg
QT_INSTALL_EXAMPLES:/data/development/sources/qt/examples
QT_INSTALL_DEMOS:/data/development/sources/qt/demos
QMAKE_MKSPECS:/data/development/sources/qt/mkspecs
QMAKE_VERSION:2.01a
QT_VERSION:4.8.0
Comment 4 Kevin Funk 2012-12-02 23:08:37 UTC
Still broken for you?
Comment 5 András Manţia 2012-12-03 10:29:38 UTC
Yes, it is.
Comment 6 András Manţia 2012-12-03 10:30:10 UTC
(Set back the status to New)
Comment 7 Kevin Funk 2014-01-29 16:14:26 UTC
I also get this (sometimes?) when working with Qt5. Can someone check what's going on here? Also very annoying.
Comment 8 Milian Wolff 2014-01-29 16:47:05 UTC
I need a project to reproduce this. It works with the steps outlined by Andras above. Maybe b/c I don't compile Qt4 on my own?

Kevin, if you can find a minimal project with Qt5, please attach it and tell me what you did to use Qt5 there.
Comment 9 Kevin Funk 2014-01-29 19:33:21 UTC
Apparently that's really problem of using self-compiled Qt and using one from /usr/include.

The subtle difference: In self-compiled Qt: The header QState includes "qstate.h" which again includes something like "../../../../src/qt/src/corelib/statemachine/qstate.h". Hence, the QState file is not considered an direct importer of  "../../../../src/qt/src/corelib/statemachine/qstate.h" and is discarded.

In Cpp::missingIncludeCompletionItems: decl->topContext()->parsingEnvironmentFile()->importers() only returns files such as '/path/to/qstate.h'.

Apparently DUContextDynamicData::addImportedChildContext is responsible for "sorting" out indirect imports. Does that make sense? Even if it does, I don't know how to fix. This is quite internal stuff.
Comment 10 Kevin Funk 2014-01-31 13:24:41 UTC
commit 38230648e0bb88bc437017ef70bb59dec31ca528
Author: Kevin Funk <kevin@kfunk.org>
Date:   Fri Jan 31 14:13:03 2014 +0100

    Introduce new technique to lookup forward headers
    
    We are now able to propose headers in the missing-include assistant,
    which were not parsed before (i.e. that are not in the DUChain).
    
    The procedure is simple: Assume we write something like 'QState',
    and qstate.h is not yet included nor parsed, in some file foo.cpp.
    KDevelop then checks if there is a file called 'QState' in
    any of the include paths required to build foo.cpp and then adds it
    to the list of possible include directives.
    
    This is possibly useful in other areas, e.g. for the "Create From
    Template" feature, as well.
Comment 11 Kevin Funk 2014-01-31 13:36:11 UTC
Git commit 30181d739a334f7a3a2b2f87afbb520db13114fd by Kevin Funk.
Committed on 31/01/2014 at 13:13.
Pushed by kfunk into branch 'master'.

Introduce new technique to lookup forward headers

We are now able to propose headers in the missing-include assistant,
which were not parsed before (i.e. that are not in the DUChain).

The procedure is simple: Assume we write something like 'QState',
and qstate.h is not yet included nor parsed, in some file foo.cpp.
KDevelop then checks if there is a file called 'QState' in
any of the include paths required to build foo.cpp and then adds it
to the list of possible include directives.

This is possibly useful in other areas, e.g. for the "Create From
Template" feature, as well.

M  +41   -24   languages/cpp/codecompletion/missingincludeitem.cpp

http://commits.kde.org/kdevelop/30181d739a334f7a3a2b2f87afbb520db13114fd