Commit c002c598 authored by Thorbjørn Lindeijer's avatar Thorbjørn Lindeijer Committed by Daniel Teske

Fixed generic project considering all files as source files

Now it will only consider C and C++ files as source files by filtering
on mime-type. This seems appropriate for now since it currently only
supports C++ projects anyway.

Also removed the list of generated files, which was always empty since
there is no way to tell the generic project which files are generated.

Task-number: QTCREATORBUG-5451

Change-Id: I12209995db4b30643af1d51123813c24d016f44c
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent d3302d83
......@@ -36,6 +36,8 @@
#include <coreplugin/documentmanager.h>
#include <coreplugin/icontext.h>
#include <coreplugin/icore.h>
#include <coreplugin/mimedatabase.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/ModelManagerInterface.h>
#include <extensionsystem/pluginmanager.h>
#include <projectexplorer/abi.h>
......@@ -248,8 +250,7 @@ void GenericProject::refresh(RefreshOptions options)
new CPlusPlus::CppModelManagerInterface::ProjectPart);
Kit *k = activeTarget() ? activeTarget()->kit() : KitManager::instance()->defaultKit();
ToolChain *tc = k ? ToolChainKitInformation::toolChain(k) : 0;
if (tc) {
if (ToolChain *tc = ToolChainKitInformation::toolChain(k)) {
QStringList cxxflags; // FIXME: Can we do better?
part->defines = tc->predefinedMacros(cxxflags);
part->defines += '\n';
......@@ -266,8 +267,21 @@ void GenericProject::refresh(RefreshOptions options)
part->defines += m_defines;
// ### add _defines.
part->sourceFiles = files();
part->sourceFiles += generated();
// Add any C/C++ files to be parsed
QStringList cppMimeTypes;
cppMimeTypes << QLatin1String(CppTools::Constants::C_SOURCE_MIMETYPE)
<< QLatin1String(CppTools::Constants::C_HEADER_MIMETYPE)
<< QLatin1String(CppTools::Constants::CPP_SOURCE_MIMETYPE)
<< QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE)
<< QLatin1String(CppTools::Constants::CPP_HEADER_MIMETYPE);
const Core::MimeDatabase *mimeDatabase = Core::ICore::mimeDatabase();
foreach (const QString &file, files()) {
const Core::MimeType mimeType = mimeDatabase->findByFile(QFileInfo(file));
if (cppMimeTypes.contains(mimeType.type()))
part->sourceFiles += file;
}
QStringList filesToUpdate;
......@@ -278,7 +292,7 @@ void GenericProject::refresh(RefreshOptions options)
m_codeModelFuture.cancel();
} else if (options & Files) {
// Only update files that got added to the list
QSet<QString> newFileList = m_files.toSet();
QSet<QString> newFileList = part->sourceFiles.toSet();
newFileList.subtract(oldFileList);
filesToUpdate.append(newFileList.toList());
}
......@@ -360,11 +374,6 @@ QStringList GenericProject::files() const
return m_files;
}
QStringList GenericProject::generated() const
{
return m_generated;
}
QStringList GenericProject::includePaths() const
{
return m_includePaths;
......@@ -408,7 +417,7 @@ GenericProjectNode *GenericProject::rootProjectNode() const
QStringList GenericProject::files(FilesMode fileMode) const
{
Q_UNUSED(fileMode)
return m_files; // ### TODO: handle generated files here.
return m_files;
}
QStringList GenericProject::buildTargets() const
......
......@@ -89,7 +89,6 @@ public:
QStringList allIncludePaths() const;
QStringList projectIncludePaths() const;
QStringList files() const;
QStringList generated() const;
protected:
bool fromMap(const QVariantMap &map);
......@@ -113,7 +112,6 @@ private:
QStringList m_rawFileList;
QStringList m_files;
QHash<QString, QString> m_rawListEntries;
QStringList m_generated;
QStringList m_includePaths;
QStringList m_projectIncludePaths;
QByteArray m_defines;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment