2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2013-01-28 17:12:19 +01:00
|
|
|
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
|
|
|
|
** General Public License version 2.1 as published by the Free Software
|
|
|
|
|
** Foundation and appearing in the file LICENSE.LGPL included in the
|
|
|
|
|
** packaging of this file. Please review the following information to
|
|
|
|
|
** ensure the GNU Lesser General Public License version 2.1 requirements
|
|
|
|
|
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
|
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 15:08:31 +01:00
|
|
|
|
2013-04-23 15:04:36 +02:00
|
|
|
#include "cpptoolsconstants.h"
|
2008-12-12 14:39:51 +01:00
|
|
|
#include "cpptoolsplugin.h"
|
2009-03-18 16:43:01 +01:00
|
|
|
#include "cppfilesettingspage.h"
|
2011-02-03 15:48:14 +01:00
|
|
|
#include "cppcodestylesettingspage.h"
|
2008-11-28 15:36:54 +01:00
|
|
|
#include "cppclassesfilter.h"
|
2008-12-09 17:15:00 +01:00
|
|
|
#include "cppfunctionsfilter.h"
|
2009-05-14 21:08:08 +02:00
|
|
|
#include "cppcurrentdocumentfilter.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "cppmodelmanager.h"
|
2009-10-16 10:55:58 +02:00
|
|
|
#include "cpplocatorfilter.h"
|
2010-07-19 14:46:53 +02:00
|
|
|
#include "symbolsfindfilter.h"
|
2011-02-03 15:48:14 +01:00
|
|
|
#include "cpptoolssettings.h"
|
2012-10-10 21:00:48 +02:00
|
|
|
#include "cpptoolsreuse.h"
|
2013-03-27 10:32:28 +04:00
|
|
|
#include "cppprojectfile.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-18 10:59:06 +01:00
|
|
|
#include <coreplugin/actionmanager/actioncontainer.h>
|
2013-03-27 18:54:03 +01:00
|
|
|
#include <coreplugin/actionmanager/actionmanager.h>
|
|
|
|
|
#include <coreplugin/coreconstants.h>
|
|
|
|
|
#include <coreplugin/documentmanager.h>
|
|
|
|
|
#include <coreplugin/icore.h>
|
2009-11-11 14:32:54 +01:00
|
|
|
#include <coreplugin/vcsmanager.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <cppeditor/cppeditorconstants.h>
|
2013-03-27 18:54:03 +01:00
|
|
|
|
2013-04-25 20:24:06 +02:00
|
|
|
#include <utils/hostosinfo.h>
|
2012-01-23 17:44:49 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2009-06-02 14:56:03 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QtPlugin>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
#include <QDir>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QAction>
|
2009-06-02 14:56:03 +02:00
|
|
|
|
|
|
|
|
using namespace CPlusPlus;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-10-10 21:00:48 +02:00
|
|
|
namespace CppTools {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
enum { debug = 0 };
|
|
|
|
|
|
2011-07-06 17:34:45 +02:00
|
|
|
static CppToolsPlugin *m_instance = 0;
|
2012-10-10 21:00:48 +02:00
|
|
|
static QHash<QString, QString> m_headerSourceMapping;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-04-29 09:04:59 +02:00
|
|
|
CppToolsPlugin::CppToolsPlugin() :
|
|
|
|
|
m_fileSettings(new CppFileSettings)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
m_instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CppToolsPlugin::~CppToolsPlugin()
|
|
|
|
|
{
|
|
|
|
|
m_instance = 0;
|
2012-10-15 16:38:56 +02:00
|
|
|
delete CppModelManager::instance();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2013-03-19 11:51:36 +01:00
|
|
|
CppToolsPlugin *CppToolsPlugin::instance()
|
|
|
|
|
{
|
|
|
|
|
return m_instance;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-20 11:52:04 +01:00
|
|
|
bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-07-13 17:35:17 +02:00
|
|
|
Q_UNUSED(arguments)
|
|
|
|
|
Q_UNUSED(error)
|
2011-05-27 09:35:47 +02:00
|
|
|
|
2011-02-03 15:48:14 +01:00
|
|
|
m_settings = new CppToolsSettings(this); // force registration of cpp tools settings
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Objects
|
2012-10-15 16:38:56 +02:00
|
|
|
CppModelManager *modelManager = CppModelManager::instance();
|
2012-01-24 15:36:40 +01:00
|
|
|
Core::VcsManager *vcsManager = Core::ICore::vcsManager();
|
2009-11-11 14:32:54 +01:00
|
|
|
connect(vcsManager, SIGNAL(repositoryChanged(QString)),
|
2012-10-15 16:38:56 +02:00
|
|
|
modelManager, SLOT(updateModifiedSourceFiles()));
|
2012-02-14 16:43:51 +01:00
|
|
|
connect(Core::DocumentManager::instance(), SIGNAL(filesChangedInternally(QStringList)),
|
2012-10-15 16:38:56 +02:00
|
|
|
modelManager, SLOT(updateSourceFiles(QStringList)));
|
2009-06-09 13:52:27 +02:00
|
|
|
|
2012-10-15 16:38:56 +02:00
|
|
|
addAutoReleasedObject(new CppLocatorFilter(modelManager));
|
|
|
|
|
addAutoReleasedObject(new CppClassesFilter(modelManager));
|
|
|
|
|
addAutoReleasedObject(new CppFunctionsFilter(modelManager));
|
2013-08-29 17:17:24 +02:00
|
|
|
addAutoReleasedObject(new CppCurrentDocumentFilter(modelManager));
|
2009-04-29 09:04:59 +02:00
|
|
|
addAutoReleasedObject(new CppFileSettingsPage(m_fileSettings));
|
2012-10-15 16:38:56 +02:00
|
|
|
addAutoReleasedObject(new SymbolsFindFilter(modelManager));
|
2011-02-03 15:48:14 +01:00
|
|
|
addAutoReleasedObject(new CppCodeStyleSettingsPage);
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
// Menus
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::ActionContainer *mtools = Core::ActionManager::actionContainer(Core::Constants::M_TOOLS);
|
|
|
|
|
Core::ActionContainer *mcpptools = Core::ActionManager::createMenu(CppTools::Constants::M_TOOLS_CPP);
|
2008-12-02 12:01:29 +01:00
|
|
|
QMenu *menu = mcpptools->menu();
|
|
|
|
|
menu->setTitle(tr("&C++"));
|
|
|
|
|
menu->setEnabled(true);
|
|
|
|
|
mtools->addMenu(mcpptools);
|
|
|
|
|
|
|
|
|
|
// Actions
|
2010-06-25 17:37:59 +02:00
|
|
|
Core::Context context(CppEditor::Constants::C_CPPEDITOR);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
QAction *switchAction = new QAction(tr("Switch Header/Source"), this);
|
2012-05-24 13:49:06 +02:00
|
|
|
Core::Command *command = Core::ActionManager::registerAction(switchAction, Constants::SWITCH_HEADER_SOURCE, context, true);
|
2008-12-02 12:01:29 +01:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Qt::Key_F4));
|
|
|
|
|
mcpptools->addAction(command);
|
|
|
|
|
connect(switchAction, SIGNAL(triggered()), this, SLOT(switchHeaderSource()));
|
|
|
|
|
|
2013-02-15 15:14:22 +01:00
|
|
|
QAction *openInNextSplitAction = new QAction(tr("Open Corresponding Header/Source in Next Split"), this);
|
2013-02-05 14:14:33 +01:00
|
|
|
command = Core::ActionManager::registerAction(openInNextSplitAction, Constants::OPEN_HEADER_SOURCE_IN_NEXT_SPLIT, context, true);
|
2013-04-25 20:24:06 +02:00
|
|
|
command->setDefaultKeySequence(QKeySequence(Utils::HostOsInfo::isMacHost()
|
|
|
|
|
? tr("Meta+E, F4")
|
|
|
|
|
: tr("Ctrl+E, F4")));
|
2013-02-05 14:14:33 +01:00
|
|
|
mcpptools->addAction(command);
|
|
|
|
|
connect(openInNextSplitAction, SIGNAL(triggered()), this, SLOT(switchHeaderSourceInNextSplit()));
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppToolsPlugin::extensionsInitialized()
|
|
|
|
|
{
|
2009-04-29 09:04:59 +02:00
|
|
|
// The Cpp editor plugin, which is loaded later on, registers the Cpp mime types,
|
|
|
|
|
// so, apply settings here
|
2012-01-24 15:36:40 +01:00
|
|
|
m_fileSettings->fromSettings(Core::ICore::settings());
|
2009-04-29 09:04:59 +02:00
|
|
|
if (!m_fileSettings->applySuffixesToMimeDB())
|
|
|
|
|
qWarning("Unable to apply cpp suffixes to mime database (cpp mime types not found).\n");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-13 13:36:47 +02:00
|
|
|
ExtensionSystem::IPlugin::ShutdownFlag CppToolsPlugin::aboutToShutdown()
|
2008-12-12 16:36:33 +01:00
|
|
|
{
|
2010-07-13 13:36:47 +02:00
|
|
|
return SynchronousShutdown;
|
2008-12-12 16:36:33 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void CppToolsPlugin::switchHeaderSource()
|
|
|
|
|
{
|
2013-02-05 14:14:33 +01:00
|
|
|
QString otherFile = correspondingHeaderOrSource(
|
2013-07-09 11:52:44 +02:00
|
|
|
Core::EditorManager::currentDocument()->filePath());
|
2013-02-05 14:14:33 +01:00
|
|
|
if (!otherFile.isEmpty())
|
|
|
|
|
Core::EditorManager::openEditor(otherFile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CppToolsPlugin::switchHeaderSourceInNextSplit()
|
|
|
|
|
{
|
|
|
|
|
QString otherFile = correspondingHeaderOrSource(
|
2013-07-09 11:52:44 +02:00
|
|
|
Core::EditorManager::currentDocument()->filePath());
|
2013-02-05 14:14:33 +01:00
|
|
|
if (!otherFile.isEmpty())
|
2013-05-31 12:52:53 +02:00
|
|
|
Core::EditorManager::openEditor(otherFile, Core::Id(), Core::EditorManager::OpenInOtherSplit);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2012-01-06 22:23:15 +01:00
|
|
|
static QStringList findFilesInProject(const QString &name,
|
2011-09-28 10:35:21 +02:00
|
|
|
const ProjectExplorer::Project *project)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
if (debug)
|
2011-09-28 10:35:21 +02:00
|
|
|
qDebug() << Q_FUNC_INFO << name << project;
|
|
|
|
|
|
|
|
|
|
if (!project)
|
2012-01-06 22:23:15 +01:00
|
|
|
return QStringList();
|
2011-09-28 10:35:21 +02:00
|
|
|
|
|
|
|
|
QString pattern = QString(1, QLatin1Char('/'));
|
|
|
|
|
pattern += name;
|
|
|
|
|
const QStringList projectFiles = project->files(ProjectExplorer::Project::AllFiles);
|
|
|
|
|
const QStringList::const_iterator pcend = projectFiles.constEnd();
|
2012-01-06 22:23:15 +01:00
|
|
|
QStringList candidateList;
|
2011-09-28 10:35:21 +02:00
|
|
|
for (QStringList::const_iterator it = projectFiles.constBegin(); it != pcend; ++it) {
|
|
|
|
|
if (it->endsWith(pattern))
|
2012-01-06 22:23:15 +01:00
|
|
|
candidateList.append(*it);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2012-01-06 22:23:15 +01:00
|
|
|
return candidateList;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return the suffixes that should be checked when trying to find a
|
|
|
|
|
// source belonging to a header and vice versa
|
2013-03-27 10:32:28 +04:00
|
|
|
static QStringList matchingCandidateSuffixes(ProjectFile::Kind kind)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2013-03-27 10:32:28 +04:00
|
|
|
Core::MimeDatabase *md = Core::ICore::instance()->mimeDatabase();
|
|
|
|
|
switch (kind) {
|
|
|
|
|
// Note that C/C++ headers are undistinguishable
|
|
|
|
|
case ProjectFile::CHeader:
|
|
|
|
|
case ProjectFile::CXXHeader:
|
|
|
|
|
case ProjectFile::ObjCHeader:
|
|
|
|
|
case ProjectFile::ObjCXXHeader:
|
|
|
|
|
return md->findByType(QLatin1String(Constants::C_SOURCE_MIMETYPE)).suffixes()
|
|
|
|
|
+ md->findByType(QLatin1String(Constants::CPP_SOURCE_MIMETYPE)).suffixes()
|
2013-05-02 11:24:34 +02:00
|
|
|
+ md->findByType(QLatin1String(Constants::OBJECTIVE_C_SOURCE_MIMETYPE)).suffixes()
|
2013-03-27 10:32:28 +04:00
|
|
|
+ md->findByType(QLatin1String(Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE)).suffixes();
|
|
|
|
|
case ProjectFile::CSource:
|
|
|
|
|
case ProjectFile::ObjCSource:
|
|
|
|
|
return md->findByType(QLatin1String(Constants::C_HEADER_MIMETYPE)).suffixes();
|
|
|
|
|
case ProjectFile::CXXSource:
|
|
|
|
|
case ProjectFile::ObjCXXSource:
|
|
|
|
|
case ProjectFile::CudaSource:
|
|
|
|
|
case ProjectFile::OpenCLSource:
|
|
|
|
|
return md->findByType(QLatin1String(Constants::CPP_HEADER_MIMETYPE)).suffixes();
|
|
|
|
|
default:
|
|
|
|
|
return QStringList();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-28 10:35:21 +02:00
|
|
|
static QStringList baseNameWithAllSuffixes(const QString &baseName, const QStringList &suffixes)
|
|
|
|
|
{
|
|
|
|
|
QStringList result;
|
|
|
|
|
const QChar dot = QLatin1Char('.');
|
|
|
|
|
foreach (const QString &suffix, suffixes) {
|
|
|
|
|
QString fileName = baseName;
|
|
|
|
|
fileName += dot;
|
|
|
|
|
fileName += suffix;
|
|
|
|
|
result += fileName;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2012-01-06 22:23:15 +01:00
|
|
|
static int commonStringLength(const QString &s1, const QString &s2)
|
|
|
|
|
{
|
|
|
|
|
int length = qMin(s1.length(), s2.length());
|
|
|
|
|
for (int i = 0; i < length; ++i)
|
|
|
|
|
if (s1[i] != s2[i])
|
|
|
|
|
return i;
|
|
|
|
|
return length;
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-21 13:13:03 +02:00
|
|
|
static QString correspondingHeaderOrSourceInProject(const QFileInfo &fileInfo,
|
|
|
|
|
const QStringList &candidateFileNames,
|
|
|
|
|
const ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
QString bestFileName;
|
|
|
|
|
int compareValue = 0;
|
|
|
|
|
const QString filePath = fileInfo.filePath();
|
|
|
|
|
foreach (const QString &candidateFileName, candidateFileNames) {
|
|
|
|
|
const QStringList projectFiles = findFilesInProject(candidateFileName, project);
|
|
|
|
|
// Find the file having the most common path with fileName
|
|
|
|
|
foreach (const QString &projectFile, projectFiles) {
|
|
|
|
|
int value = commonStringLength(filePath, projectFile);
|
|
|
|
|
if (value > compareValue) {
|
|
|
|
|
compareValue = value;
|
|
|
|
|
bestFileName = projectFile;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!bestFileName.isEmpty()) {
|
|
|
|
|
const QFileInfo candidateFi(bestFileName);
|
|
|
|
|
QTC_ASSERT(candidateFi.isFile(), return QString());
|
|
|
|
|
m_headerSourceMapping[fileInfo.absoluteFilePath()] = candidateFi.absoluteFilePath();
|
|
|
|
|
m_headerSourceMapping[candidateFi.absoluteFilePath()] = fileInfo.absoluteFilePath();
|
|
|
|
|
return candidateFi.absoluteFilePath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-10 21:00:48 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
|
|
|
|
|
QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2012-10-10 21:00:48 +02:00
|
|
|
using namespace Internal;
|
2012-01-08 16:00:32 +01:00
|
|
|
|
2012-10-10 21:00:48 +02:00
|
|
|
const QFileInfo fi(fileName);
|
2013-03-27 10:32:28 +04:00
|
|
|
ProjectFile::Kind kind = ProjectFile::classify(fileName);
|
|
|
|
|
const bool isHeader = ProjectFile::isHeader(kind);
|
2013-04-10 11:48:47 +02:00
|
|
|
if (wasHeader)
|
2013-03-27 10:32:28 +04:00
|
|
|
*wasHeader = isHeader;
|
|
|
|
|
if (m_headerSourceMapping.contains(fi.absoluteFilePath()))
|
2012-10-10 21:00:48 +02:00
|
|
|
return m_headerSourceMapping.value(fi.absoluteFilePath());
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
if (debug)
|
2013-03-27 10:32:28 +04:00
|
|
|
qDebug() << Q_FUNC_INFO << fileName << kind;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2013-03-27 10:32:28 +04:00
|
|
|
if (kind == ProjectFile::Unclassified)
|
2008-12-02 12:01:29 +01:00
|
|
|
return QString();
|
|
|
|
|
|
2009-03-16 11:17:45 +01:00
|
|
|
const QString baseName = fi.completeBaseName();
|
2011-09-28 10:35:21 +02:00
|
|
|
const QString privateHeaderSuffix = QLatin1String("_p");
|
2013-03-27 10:32:28 +04:00
|
|
|
const QStringList suffixes = matchingCandidateSuffixes(kind);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2011-09-28 10:35:21 +02:00
|
|
|
QStringList candidateFileNames = baseNameWithAllSuffixes(baseName, suffixes);
|
2013-03-27 10:32:28 +04:00
|
|
|
if (isHeader) {
|
2008-12-02 12:01:29 +01:00
|
|
|
if (baseName.endsWith(privateHeaderSuffix)) {
|
|
|
|
|
QString sourceBaseName = baseName;
|
|
|
|
|
sourceBaseName.truncate(sourceBaseName.size() - privateHeaderSuffix.size());
|
2011-09-28 10:35:21 +02:00
|
|
|
candidateFileNames += baseNameWithAllSuffixes(sourceBaseName, suffixes);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
} else {
|
2011-09-28 10:35:21 +02:00
|
|
|
QString privateHeaderBaseName = baseName;
|
|
|
|
|
privateHeaderBaseName.append(privateHeaderSuffix);
|
|
|
|
|
candidateFileNames += baseNameWithAllSuffixes(privateHeaderBaseName, suffixes);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const QDir absoluteDir = fi.absoluteDir();
|
|
|
|
|
|
|
|
|
|
// Try to find a file in the same directory first
|
2012-01-06 22:23:15 +01:00
|
|
|
foreach (const QString &candidateFileName, candidateFileNames) {
|
|
|
|
|
const QFileInfo candidateFi(absoluteDir, candidateFileName);
|
2012-01-08 16:00:32 +01:00
|
|
|
if (candidateFi.isFile()) {
|
|
|
|
|
m_headerSourceMapping[fi.absoluteFilePath()] = candidateFi.absoluteFilePath();
|
2013-03-27 10:32:28 +04:00
|
|
|
if (!isHeader || !baseName.endsWith(privateHeaderSuffix))
|
2012-06-21 20:55:17 -07:00
|
|
|
m_headerSourceMapping[candidateFi.absoluteFilePath()] = fi.absoluteFilePath();
|
2011-09-28 10:35:21 +02:00
|
|
|
return candidateFi.absoluteFilePath();
|
2012-01-08 16:00:32 +01:00
|
|
|
}
|
2011-09-28 10:35:21 +02:00
|
|
|
}
|
|
|
|
|
|
2013-06-21 13:13:03 +02:00
|
|
|
// Find files in the current project
|
|
|
|
|
ProjectExplorer::Project *currentProject = ProjectExplorer::ProjectExplorerPlugin::currentProject();
|
|
|
|
|
if (currentProject) {
|
|
|
|
|
const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames,
|
|
|
|
|
currentProject);
|
|
|
|
|
if (!path.isEmpty())
|
|
|
|
|
return path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find files in other projects
|
|
|
|
|
CppModelManager *modelManager = CppModelManager::instance();
|
|
|
|
|
QList<CppModelManagerInterface::ProjectInfo> projectInfos = modelManager->projectInfos();
|
|
|
|
|
foreach (const CppModelManagerInterface::ProjectInfo &projectInfo, projectInfos) {
|
|
|
|
|
const ProjectExplorer::Project *project = projectInfo.project().data();
|
|
|
|
|
if (project == currentProject)
|
|
|
|
|
continue; // We have already checked the current project.
|
|
|
|
|
|
|
|
|
|
const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames, project);
|
|
|
|
|
if (!path.isEmpty())
|
|
|
|
|
return path;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
2011-09-28 10:35:21 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
return QString();
|
|
|
|
|
}
|
|
|
|
|
|
2012-10-10 21:00:48 +02:00
|
|
|
} // namespace CppTools
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-10-10 21:00:48 +02:00
|
|
|
Q_EXPORT_PLUGIN(CppTools::Internal::CppToolsPlugin)
|