Merge remote-tracking branch 'origin/3.2'

Conflicts:
	qtcreator.pri
	qtcreator.qbs
	src/plugins/android/androidglobal.h

Change-Id: I3367bf2ea47c088989175dddeed2210294346f4c
This commit is contained in:
Oswald Buddenhagen
2014-08-05 14:24:23 +02:00
239 changed files with 3370 additions and 2107 deletions

View File

@@ -168,7 +168,9 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
MyTestDataDir testDirectory(QLatin1String("testdata_basic"));
const QString testFile = testDirectory.file(QLatin1String("file1.cpp"));
const QString objTestFile = testDirectory.file(QLatin1String("file1.mm"));
const QString testFileShort = FileUtils::shortNativePath(FileName::fromString(testFile));
const QString objTestFileShort = FileUtils::shortNativePath(FileName::fromString(objTestFile));
QTest::newRow("CppFunctionsFilter")
<< testFile
@@ -247,6 +249,27 @@ void CppToolsPlugin::test_cpplocatorfilters_CppLocatorFilter_data()
<< ResultData(_("MyNamespace::myFunction"), _("(bool, int)"))
<< ResultData(_("myFunction"), _("(bool, int)"))
);
QTest::newRow("CppClassesFilter-ObjC")
<< objTestFile
<< cppClassesFilter
<< _("M")
<< (QList<ResultData>()
<< ResultData(_("MyClass"), objTestFileShort)
<< ResultData(_("MyClass"), objTestFileShort)
<< ResultData(_("MyClass"), objTestFileShort)
<< ResultData(_("MyProtocol"), objTestFileShort)
);
QTest::newRow("CppFunctionsFilter-ObjC")
<< objTestFile
<< cppFunctionsFilter
<< _("M")
<< (QList<ResultData>()
<< ResultData(_("anotherMethod"), _("MyClass"))
<< ResultData(_("anotherMethod:"), _("MyClass"))
<< ResultData(_("someMethod"), _("MyClass"))
);
}
void CppToolsPlugin::test_cpplocatorfilters_CppCurrentDocumentFilter()

View File

@@ -37,6 +37,8 @@
#include <coreplugin/testdatadir.h>
#include <projectexplorer/projectexplorer.h>
#include <projectexplorer/session.h>
#include <cplusplus/LookupContext.h>
#include <utils/hostosinfo.h>
#include <QDebug>
@@ -873,7 +875,7 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
}
}
void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
void CppToolsPlugin::test_modelmanager_precompiled_headers()
{
ModelManagerTestHelper helper;
@@ -922,14 +924,16 @@ void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
struct Data {
QString firstDeclarationName;
QString firstClassInPchFile;
QString fileName;
} d[] = {
{ _("one"), main1File },
{ _("two"), main2File }
{ _("one"), _("ClassInPch1"), main1File },
{ _("two"), _("ClassInPch2"), main2File }
};
const int size = sizeof(d) / sizeof(d[0]);
for (int i = 0; i < size; ++i) {
const QString firstDeclarationName = d[i].firstDeclarationName;
const QByteArray firstClassInPchFile = d[i].firstClassInPchFile.toUtf8();
const QString fileName = d[i].fileName;
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
@@ -943,11 +947,22 @@ void CppToolsPlugin::test_modelmanager_defines_per_project_pch()
while (sup->lastSemanticInfoDocument().isNull())
QCoreApplication::processEvents();
sup->snapshotUpdater()->setUsePrecompiledHeaders(true);
sup->snapshotUpdater()->update(mm->workingCopy());
const QSharedPointer<SnapshotUpdater> updater = sup->snapshotUpdater();
updater->setUsePrecompiledHeaders(true);
updater->update(mm->workingCopy());
Document::Ptr doc = mm->document(fileName);
QCOMPARE(nameOfFirstDeclaration(doc), firstDeclarationName);
// Check if defines from pch are considered
Document::Ptr document = mm->document(fileName);
QCOMPARE(nameOfFirstDeclaration(document), firstDeclarationName);
// Check if declarations from pch are considered
CPlusPlus::LookupContext context(document, updater->snapshot());
const CPlusPlus::Identifier *identifier
= document->control()->identifier(firstClassInPchFile.data());
const QList<CPlusPlus::LookupItem> results = context.lookup(identifier,
document->globalNamespace());
QVERIFY(!results.isEmpty());
QVERIFY(results.first().declaration()->type()->asClassType());
}
}

View File

@@ -177,7 +177,8 @@ void SnapshotUpdater::update(CppModelManager::WorkingCopy workingCopy)
}
if (!m_editorDefines.isEmpty())
sourceProcessor.run(editorDefinesFileName);
sourceProcessor.run(m_fileInEditor);
sourceProcessor.run(m_fileInEditor, m_usePrecompiledHeaders ? m_precompiledHeaders
: QStringList());
m_snapshot = sourceProcessor.snapshot();
Snapshot newSnapshot = m_snapshot.simplified(document());

View File

@@ -148,9 +148,10 @@ void CppSourceProcessor::addFrameworkPath(const ProjectPart::HeaderPath &framewo
void CppSourceProcessor::setTodo(const QStringList &files)
{ m_todo = QSet<QString>::fromList(files); }
void CppSourceProcessor::run(const QString &fileName)
void CppSourceProcessor::run(const QString &fileName,
const QStringList &initialIncludes)
{
sourceNeeded(0, fileName, IncludeGlobal);
sourceNeeded(0, fileName, IncludeGlobal, initialIncludes);
}
void CppSourceProcessor::removeFromCache(const QString &fileName)
@@ -377,7 +378,8 @@ void CppSourceProcessor::stopSkippingBlocks(unsigned utf16charsOffset)
m_currentDoc->stopSkippingBlocks(utf16charsOffset);
}
void CppSourceProcessor::sourceNeeded(unsigned line, const QString &fileName, IncludeType type)
void CppSourceProcessor::sourceNeeded(unsigned line, const QString &fileName, IncludeType type,
const QStringList &initialIncludes)
{
if (fileName.isEmpty())
return;
@@ -417,6 +419,11 @@ void CppSourceProcessor::sourceNeeded(unsigned line, const QString &fileName, In
Document::Ptr document = Document::create(absoluteFileName);
document->setRevision(m_revision);
document->setEditorRevision(editorRevision);
foreach (const QString &include, initialIncludes) {
m_included.insert(include);
Document::Include inc(include, include, 0, IncludeLocal);
document->addIncludeFile(inc);
}
const QFileInfo info(absoluteFileName);
if (info.exists())
document->setLastModified(info.lastModified());

View File

@@ -43,7 +43,7 @@ public:
void setHeaderPaths(const ProjectPart::HeaderPaths &headerPaths);
void setTodo(const QStringList &files);
void run(const QString &fileName);
void run(const QString &fileName, const QStringList &initialIncludes = QStringList());
void removeFromCache(const QString &fileName);
void resetEnvironment();
@@ -80,7 +80,8 @@ private:
void markAsIncludeGuard(const QByteArray &macroName) QTC_OVERRIDE;
void startSkippingBlocks(unsigned utf16charsOffset) QTC_OVERRIDE;
void stopSkippingBlocks(unsigned utf16charsOffset) QTC_OVERRIDE;
void sourceNeeded(unsigned line, const QString &fileName, IncludeType type) QTC_OVERRIDE;
void sourceNeeded(unsigned line, const QString &fileName, IncludeType type,
const QStringList &initialIncludes) QTC_OVERRIDE;
private:
CPlusPlus::Snapshot m_snapshot;

View File

@@ -429,19 +429,20 @@ QString correspondingHeaderOrSource(const QString &fileName, bool *wasHeader)
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.
} else {
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;
const QString path = correspondingHeaderOrSourceInProject(fi, candidateFileNames, project);
if (!path.isEmpty())
return path;
}
}
return QString();

View File

@@ -150,8 +150,8 @@ private slots:
void test_modelmanager_gc_if_last_cppeditor_closed();
void test_modelmanager_dont_gc_opened_files();
void test_modelmanager_defines_per_project();
void test_modelmanager_defines_per_project_pch();
void test_modelmanager_defines_per_editor();
void test_modelmanager_precompiled_headers();
void test_cpplocatorfilters_CppLocatorFilter();
void test_cpplocatorfilters_CppLocatorFilter_data();

View File

@@ -105,11 +105,7 @@ bool SearchSymbols::visit(Enum *symbol)
bool SearchSymbols::visit(Function *symbol)
{
if (!(symbolsToSearchFor & SymbolSearcher::Functions) || !symbol->name())
return false;
QString name = overview.prettyName(symbol->name());
QString type = overview.prettyType(symbol->type());
addChildItem(name, type, _scope, IndexItem::Function, symbol);
processFunction(symbol);
return false;
}
@@ -130,10 +126,12 @@ bool SearchSymbols::visit(Declaration *symbol)
// if we're searching for functions, still allow signal declarations to show up.
if (symbolsToSearchFor & SymbolSearcher::Functions) {
Function *funTy = symbol->type()->asFunctionType();
if (!funTy)
return false;
if (!funTy->isSignal())
if (!funTy) {
if (!symbol->type()->asObjCMethodType())
return false;
} else if (!funTy->isSignal()) {
return false;
}
} else {
return false;
}
@@ -153,19 +151,7 @@ bool SearchSymbols::visit(Declaration *symbol)
bool SearchSymbols::visit(Class *symbol)
{
QString name = overview.prettyName(symbol->name());
IndexItem::Ptr newParent;
if (symbolsToSearchFor & SymbolSearcher::Classes)
newParent = addChildItem(name, QString(), _scope, IndexItem::Class, symbol);
if (!newParent)
newParent = _parent;
ScopedIndexItemPtr parentRaii(_parent, newParent);
QString newScope = scopedSymbolName(name, symbol);
ScopedScope scopeRaii(_scope, newScope);
for (unsigned i = 0, ei = symbol->memberCount(); i != ei; ++i)
accept(symbol->memberAt(i));
processClass(symbol);
return false;
}
@@ -225,8 +211,10 @@ bool SearchSymbols::visit(CPlusPlus::ObjCBaseProtocol *)
return false;
}
bool SearchSymbols::visit(CPlusPlus::ObjCClass *)
bool SearchSymbols::visit(CPlusPlus::ObjCClass *symbol)
{
processClass(symbol);
return false;
}
@@ -235,8 +223,10 @@ bool SearchSymbols::visit(CPlusPlus::ObjCForwardClassDeclaration *)
return false;
}
bool SearchSymbols::visit(CPlusPlus::ObjCProtocol *)
bool SearchSymbols::visit(CPlusPlus::ObjCProtocol *symbol)
{
processClass(symbol);
return false;
}
@@ -245,13 +235,15 @@ bool SearchSymbols::visit(CPlusPlus::ObjCForwardProtocolDeclaration *)
return false;
}
bool SearchSymbols::visit(CPlusPlus::ObjCMethod *)
bool SearchSymbols::visit(CPlusPlus::ObjCMethod *symbol)
{
processFunction(symbol);
return false;
}
bool SearchSymbols::visit(CPlusPlus::ObjCPropertyDeclaration *)
bool SearchSymbols::visit(CPlusPlus::ObjCPropertyDeclaration *symbol)
{
processFunction(symbol);
return false;
}
@@ -315,3 +307,31 @@ IndexItem::Ptr SearchSymbols::addChildItem(const QString &symbolName, const QStr
_parent->addChild(newItem);
return newItem;
}
template<class T>
void SearchSymbols::processClass(T *clazz)
{
QString name = overview.prettyName(clazz->name());
IndexItem::Ptr newParent;
if (symbolsToSearchFor & SymbolSearcher::Classes)
newParent = addChildItem(name, QString(), _scope, IndexItem::Class, clazz);
if (!newParent)
newParent = _parent;
ScopedIndexItemPtr parentRaii(_parent, newParent);
QString newScope = scopedSymbolName(name, clazz);
ScopedScope scopeRaii(_scope, newScope);
for (unsigned i = 0, ei = clazz->memberCount(); i != ei; ++i)
accept(clazz->memberAt(i));
}
template<class T>
void SearchSymbols::processFunction(T *func)
{
if (!(symbolsToSearchFor & SymbolSearcher::Functions) || !func->name())
return;
QString name = overview.prettyName(func->name());
QString type = overview.prettyType(func->type());
addChildItem(name, type, _scope, IndexItem::Function, func);
}

View File

@@ -85,12 +85,12 @@ protected:
// Objective-C
virtual bool visit(CPlusPlus::ObjCBaseClass *);
virtual bool visit(CPlusPlus::ObjCBaseProtocol *);
virtual bool visit(CPlusPlus::ObjCClass *);
virtual bool visit(CPlusPlus::ObjCClass *symbol);
virtual bool visit(CPlusPlus::ObjCForwardClassDeclaration *);
virtual bool visit(CPlusPlus::ObjCProtocol *);
virtual bool visit(CPlusPlus::ObjCProtocol *symbol);
virtual bool visit(CPlusPlus::ObjCForwardProtocolDeclaration *);
virtual bool visit(CPlusPlus::ObjCMethod *);
virtual bool visit(CPlusPlus::ObjCPropertyDeclaration *);
virtual bool visit(CPlusPlus::ObjCMethod *symbol);
virtual bool visit(CPlusPlus::ObjCPropertyDeclaration *symbol);
QString scopedSymbolName(const QString &symbolName, const CPlusPlus::Symbol *symbol) const;
QString scopedSymbolName(const CPlusPlus::Symbol *symbol) const;
@@ -99,6 +99,10 @@ protected:
const QString &symbolScope, IndexItem::ItemType type,
CPlusPlus::Symbol *symbol);
private:
template<class T> void processClass(T *clazz);
template<class T> void processFunction(T *func);
private:
QString findOrInsert(const QString &s)
{ return strings.insert(s); }