Files
qt-creator/src/plugins/clangcodemodel/clangcodemodel.qbs
Nikolai Kosjar 2b9e9ebbfc Clang: Work around libclang not accepting not existing unsaved files
Feeding libclang with unsaved files (e.g. in-memory generated ui_*.h)
that do not exist on disk leads to regeneration of the preamble on every
parse/reparse/completion and thus renders the clang code model useless.

We could check the existence in the file system for every unsaved file
just before every parse/reparse/completion. Obviously this does not
scale (e.g. qtcreator.pro generates about 200 unsaves files) and would
also slow down the responsiveness of the completion, especially for the
dot-to-arrow correction case.

We could also set up a file system watcher. However, implementing the
"file got created" case is not trivial because QFileSystemWatcher does
not support it out of the box.

Instead, set up a custom include directory and create empty files in it
that represent the unsaved files and pass that include directory to
libclang as the last one. While this fixes the performance problems, it
also comes with at least two problems:

  * Because ui_*.h files are "relocated" to the same directory, two or
    more "foo.ui" in the same session will be problematic.

  * Because of the custom include directory, problems might arise for
    projects that include the ui_*.h as "some/relative/path/ui_foo.h"
    instead of "ui_foo.h". This should be the less common case.

Task-number: QTCREATORBUG-17245
Change-Id: I6e40e87c3ef095086eb22c972dd8c1a6459a8245
Reviewed-by: Marco Bubke <marco.bubke@qt.io>
2016-11-22 12:21:14 +00:00

124 lines
3.9 KiB
QML

import qbs
import qbs.FileInfo
QtcPlugin {
name: "ClangCodeModel"
Depends { name: "Qt"; submodules: ["concurrent", "widgets"] }
Depends { name: "Core" }
Depends { name: "CppTools" }
Depends { name: "ProjectExplorer" }
Depends { name: "TextEditor" }
Depends { name: "Utils" }
Depends { name: "ClangBackEndIpc" }
Depends { name: "libclang"; required: false }
pluginTestDepends: [
"CppEditor",
"QmakeProjectManager",
]
condition: libclang.present
cpp.defines: {
var defines = base;
// The following defines are used to determine the clang include path for intrinsics.
defines.push('CLANG_VERSION="' + libclang.llvmVersion + '"');
var resourceDir = FileInfo.joinPaths(libclang.llvmLibDir, "clang", libclang.llvmVersion,
"include");
defines.push('CLANG_RESOURCE_DIR="' + resourceDir + '"');
return defines;
}
files: [
"clangactivationsequencecontextprocessor.cpp",
"clangactivationsequencecontextprocessor.h",
"clangactivationsequenceprocessor.cpp",
"clangactivationsequenceprocessor.h",
"clangassistproposal.cpp",
"clangassistproposal.h",
"clangassistproposalitem.cpp",
"clangassistproposalitem.h",
"clangassistproposalmodel.cpp",
"clangassistproposalmodel.h",
"clangbackendipcintegration.cpp",
"clangbackendipcintegration.h",
"clangcodemodelplugin.cpp",
"clangcodemodelplugin.h",
"clangcodemodel.qrc",
"clangcompletionassistinterface.cpp",
"clangcompletionassistinterface.h",
"clangcompletionassistprocessor.cpp",
"clangcompletionassistprocessor.h",
"clangcompletionassistprovider.cpp",
"clangcompletionassistprovider.h",
"clangcompletionchunkstotextconverter.cpp",
"clangcompletionchunkstotextconverter.h",
"clangcompletioncontextanalyzer.cpp",
"clangcompletioncontextanalyzer.h",
"clangconstants.h",
"clangdiagnosticfilter.cpp",
"clangdiagnosticfilter.h",
"clangdiagnosticmanager.cpp",
"clangdiagnosticmanager.h",
"clangdiagnostictooltipwidget.cpp",
"clangdiagnostictooltipwidget.h",
"clangeditordocumentparser.cpp",
"clangeditordocumentparser.h",
"clangeditordocumentprocessor.cpp",
"clangeditordocumentprocessor.h",
"clangfixitoperation.cpp",
"clangfixitoperation.h",
"clangfixitoperationsextractor.cpp",
"clangfixitoperationsextractor.h",
"clangfunctionhintmodel.cpp",
"clangfunctionhintmodel.h",
"clanghighlightingmarksreporter.cpp",
"clanghighlightingmarksreporter.h",
"clangisdiagnosticrelatedtolocation.h",
"clangmodelmanagersupport.cpp",
"clangmodelmanagersupport.h",
"clangpreprocessorassistproposalitem.cpp",
"clangpreprocessorassistproposalitem.h",
"clangprojectsettings.cpp",
"clangprojectsettings.h",
"clangprojectsettingswidget.cpp",
"clangprojectsettingswidget.h",
"clangprojectsettingswidget.ui",
"clangtextmark.cpp",
"clangtextmark.h",
"clanguiheaderondiskmanager.cpp",
"clanguiheaderondiskmanager.h",
"clangutils.cpp",
"clangutils.h",
]
Group {
name: "Tests"
condition: qtc.testsEnabled
prefix: "test/"
files: [
"data/clangtestdata.qrc",
"clangcodecompletion_test.cpp",
"clangcodecompletion_test.h",
]
}
Group {
name: "Test resources"
prefix: "test/data/"
fileTags: []
files: [ "*" ]
excludeFiles: "clangtestdata.qrc"
}
Group {
name: "Other files"
fileTags: []
files: [
"README",
project.ide_source_tree + "/doc/src/editors/creator-clang-codemodel.qdoc",
]
}
}