Merge remote-tracking branch 'origin/3.4'

Conflicts:
	src/libs/timeline/qml/MainView.qml
	src/plugins/git/gitclient.cpp

Change-Id: I0b6ec7b9a592014deb0dd2e1145b19dd6753b1c3
This commit is contained in:
Eike Ziller
2015-04-15 17:45:47 +02:00
65 changed files with 2457 additions and 1578 deletions

View File

@@ -162,6 +162,16 @@ private:
IEditor *m_editor;
};
bool isProbablyGlobalCompletion(const QStringList &list)
{
const int numberOfPrimitivesAndBasicKeywords = (T_LAST_PRIMITIVE - T_FIRST_PRIMITIVE)
+ (T_FIRST_OBJC_AT_KEYWORD - T_FIRST_KEYWORD);
return list.size() >= numberOfPrimitivesAndBasicKeywords
&& list.contains(QLatin1String("if"))
&& list.contains(QLatin1String("bool"));
}
} // anonymous namespace
void CppToolsPlugin::test_completion_basic_1()
@@ -329,6 +339,31 @@ void CppToolsPlugin::test_completion()
QCOMPARE(actualCompletions, expectedCompletions);
}
void CppToolsPlugin::test_global_completion_data()
{
QTest::addColumn<QByteArray>("code");
QTest::addColumn<QByteArray>("prefix");
// Check that special completion after '&' for Qt5 signal/slots does not
// interfere global completion after '&'
QTest::newRow("global completion after & in return expression")
<< _("void f() { foo(myObject, @); }\n")
<< _("&");
QTest::newRow("global completion after & in function argument")
<< _("int f() { return @; }\n")
<< _("&");
}
void CppToolsPlugin::test_global_completion()
{
QFETCH(QByteArray, code);
QFETCH(QByteArray, prefix);
CompletionTestCase test(code, prefix);
QVERIFY(test.succeededSoFar());
QVERIFY(isProbablyGlobalCompletion(test.getCompletions()));
}
static void enumTestCase(const QByteArray &tag, const QByteArray &source,
const QByteArray &prefix = QByteArray())
{
@@ -2339,14 +2374,6 @@ void CppToolsPlugin::test_completion_data()
<< QLatin1String("hiddenFunction")
<< QLatin1String("hiddenSignal"));
QTest::newRow("Qt5 signals: no class name completion if not after 'connect(' 1")
<< commonSignalSlotCompletionTestCode
<< _("foo(myObject, &") << (QStringList());
QTest::newRow("Qt5 signals/slots: no class name completion if not after 'connect(' 2")
<< commonSignalSlotCompletionTestCode
<< _("&") << (QStringList());
QTest::newRow("Qt5 signals: fallback to scope completion")
<< commonSignalSlotCompletionTestCode
<< _("connect(myObject, &N::") << (QStringList()

View File

@@ -1128,8 +1128,14 @@ int InternalCppCompletionAssistProcessor::startCompletionHelper()
// "connect(sender, &" or
// "connect(otherSender, &Foo::signal1, receiver, &"
const int beforeExpression = startOfExpression - 1;
if (canCompleteClassNameAt2ndOr4thConnectArgument(m_interface.data(), beforeExpression))
if (canCompleteClassNameAt2ndOr4thConnectArgument(m_interface.data(),
beforeExpression)) {
m_model->m_completionOperator = CompleteQt5SignalOrSlotClassNameTrigger;
} else { // Ensure global completion
startOfExpression = endOfExpression = m_startPosition;
expression.clear();
m_model->m_completionOperator = T_EOF_SYMBOL;
}
} else if (m_model->m_completionOperator == T_COLON_COLON) {
// We expect 'expression' to be "Foo" in
// "connect(sender, &Foo::" or

View File

@@ -86,6 +86,8 @@ void ProjectPart::evaluateToolchain(const ToolChain *tc,
languageVersion = CXX14;
else if (flags & ToolChain::StandardCxx11)
languageVersion = CXX11;
else if (flags & ToolChain::StandardCxx98)
languageVersion = CXX98;
else
languageVersion = CXX11;

View File

@@ -112,6 +112,9 @@ private slots:
void test_completion_data();
void test_completion();
void test_global_completion_data();
void test_global_completion();
void test_completion_member_access_operator_data();
void test_completion_member_access_operator();

View File

@@ -41,6 +41,7 @@
#include <texteditor/codeassist/iassistproposalmodel.h>
#include <cplusplus/CppDocument.h>
#include <utils/executeondestruction.h>
#include <utils/fileutils.h>
#include <QtTest>
@@ -228,27 +229,30 @@ bool TestCase::writeFile(const QString &filePath, const QByteArray &contents)
return true;
}
ProjectOpenerAndCloser::ProjectOpenerAndCloser(bool waitForFinishedGcOnDestruction)
: m_waitForFinishedGcOnDestruction(waitForFinishedGcOnDestruction)
, m_gcFinished(false)
ProjectOpenerAndCloser::ProjectOpenerAndCloser()
{
QVERIFY(!SessionManager::hasProjects());
if (m_waitForFinishedGcOnDestruction) {
CppModelManager *mm = CppModelManager::instance();
connect(mm, &CppModelManager::gcFinished, this, &ProjectOpenerAndCloser::onGcFinished);
}
}
ProjectOpenerAndCloser::~ProjectOpenerAndCloser()
{
if (m_openProjects.isEmpty())
return;
bool hasGcFinished = false;
QMetaObject::Connection connection;
Utils::ExecuteOnDestruction disconnect([&]() { QObject::disconnect(connection); });
connection = QObject::connect(CppModelManager::instance(), &CppModelManager::gcFinished, [&]() {
hasGcFinished = true;
});
foreach (Project *project, m_openProjects)
ProjectExplorerPlugin::unloadProject(project);
if (m_waitForFinishedGcOnDestruction) {
m_gcFinished = false;
while (!m_gcFinished)
QCoreApplication::processEvents();
}
QTime t;
t.start();
while (!hasGcFinished && t.elapsed() <= 30000)
QCoreApplication::processEvents();
}
ProjectInfo ProjectOpenerAndCloser::open(const QString &projectFile, bool configureAsExampleProject)
@@ -259,22 +263,18 @@ ProjectInfo ProjectOpenerAndCloser::open(const QString &projectFile, bool config
qWarning() << error;
if (!project)
return ProjectInfo();
m_openProjects.append(project);
if (configureAsExampleProject)
project->configureAsExampleProject(QStringList());
if (TestCase::waitUntilCppModelManagerIsAwareOf(project))
if (TestCase::waitUntilCppModelManagerIsAwareOf(project)) {
m_openProjects.append(project);
return CppModelManager::instance()->projectInfo(project);
}
return ProjectInfo();
}
void ProjectOpenerAndCloser::onGcFinished()
{
m_gcFinished = true;
}
TemporaryDir::TemporaryDir()
: m_temporaryDir(QFileInfo(QDir::tempPath()).canonicalFilePath()
+ QLatin1String("/qtcreator-tests-XXXXXX"))

View File

@@ -117,21 +117,15 @@ private:
bool m_runGarbageCollector;
};
class CPPTOOLS_EXPORT ProjectOpenerAndCloser : public QObject
class CPPTOOLS_EXPORT ProjectOpenerAndCloser
{
Q_OBJECT
public:
ProjectOpenerAndCloser(bool waitForFinishedGcOnDestruction = true);
ProjectOpenerAndCloser();
~ProjectOpenerAndCloser(); // Closes opened projects
ProjectInfo open(const QString &projectFile, bool configureAsExampleProject = false);
private:
void onGcFinished();
bool m_waitForFinishedGcOnDestruction;
bool m_gcFinished;
QList<ProjectExplorer::Project *> m_openProjects;
};