diff options
author | Erik Verbruggen <erik.verbruggen@digia.com> | 2013-12-10 14:37:32 +0100 |
---|---|---|
committer | hjk <hjk121@nokiamail.com> | 2013-12-20 17:05:09 +0100 |
commit | 5beb74fd9d11b31b360e0a336e269b81cbca1f5a (patch) | |
tree | 6b1bad7c9798e29c694e216f1196e0f47b77ceff /src/plugins/clangcodemodel/test | |
parent | 93b7528431857d67aa0ffdc60f835d987aa7b101 (diff) | |
download | qt-creator-5beb74fd9d11b31b360e0a336e269b81cbca1f5a.tar.gz |
Add experimental clang code-model plug-in.
Previously known as the wip/clang branch.
Contributors (in alphabetical order):
- Christian Kamm <christian.d.kamm@nokia.com>
- Erik Verbruggen <erik.verbruggen@digia.com>
- Leandro Melo <leandro.melo@nokia.com>
- Peter Kuemmel <syntheticpp@gmx.net>
- Sergey Shambir <sergey.shambir.auto@gmail.com>
Change-Id: I4c3ff600a19b6732641c1d5ef28236bf2cc17737
Reviewed-by: hjk <hjk121@nokiamail.com>
Diffstat (limited to 'src/plugins/clangcodemodel/test')
20 files changed, 1458 insertions, 0 deletions
diff --git a/src/plugins/clangcodemodel/test/clang_tests_database.qrc b/src/plugins/clangcodemodel/test/clang_tests_database.qrc new file mode 100644 index 0000000000..0014d36087 --- /dev/null +++ b/src/plugins/clangcodemodel/test/clang_tests_database.qrc @@ -0,0 +1,20 @@ +<RCC> + <qresource prefix="/unittests/ClangCodeModel"> + <file>cxx_regression_1.cpp</file> + <file>cxx_regression_2.cpp</file> + <file>cxx_regression_3.cpp</file> + <file>cxx_regression_4.cpp</file> + <file>cxx_regression_5.cpp</file> + <file>cxx_regression_6.cpp</file> + <file>cxx_regression_7.cpp</file> + <file>cxx_regression_8.cpp</file> + <file>cxx_regression_9.cpp</file> + <file>cxx_snippets_1.cpp</file> + <file>cxx_snippets_2.cpp</file> + <file>cxx_snippets_3.cpp</file> + <file>cxx_snippets_4.cpp</file> + <file>objc_messages_1.mm</file> + <file>objc_messages_2.mm</file> + <file>objc_messages_3.mm</file> + </qresource> +</RCC> diff --git a/src/plugins/clangcodemodel/test/clangcompletion_test.cpp b/src/plugins/clangcodemodel/test/clangcompletion_test.cpp new file mode 100644 index 0000000000..0214051705 --- /dev/null +++ b/src/plugins/clangcodemodel/test/clangcompletion_test.cpp @@ -0,0 +1,392 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/** + * @file clangcompletion_test.cpp + * @brief Performs test for C/C++ code completion + * + * All test cases given as strings with @ character that points to completion + * location. + */ + +#ifdef WITH_TESTS + +// Disabled because there still no tool to detect system Objective-C headers +#define ENABLE_OBJC_TESTS 0 + +#include <QtTest> +#include <QDebug> +#undef interface // Canceling "#DEFINE interface struct" on Windows + +#include "completiontesthelper.h" +#include "../clangcodemodelplugin.h" + +using namespace ClangCodeModel; +using namespace ClangCodeModel::Internal; + +//////////////////////////////////////////////////////////////////////////////// +// Test cases + +/** + * \defgroup Regression tests + * + * This group tests possible regressions in non-standard completion chunks + * handling: for example, macro arguments and clang's code snippets. + * + * @{ + */ + +void ClangCodeModelPlugin::test_CXX_regressions() +{ + QFETCH(QString, file); + QFETCH(QStringList, unexpected); + QFETCH(QStringList, mustHave); + + CompletionTestHelper helper; + helper << file; + + QStringList proposals = helper.codeCompleteTexts(); + + foreach (const QString &p, unexpected) + QTEST_ASSERT(false == proposals.contains(p)); + + foreach (const QString &p, mustHave) + QTEST_ASSERT(true == proposals.contains(p)); +} + +void ClangCodeModelPlugin::test_CXX_regressions_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QStringList>("unexpected"); + QTest::addColumn<QStringList>("mustHave"); + + QString file; + QStringList unexpected; + QStringList mustHave; + + file = QLatin1String("cxx_regression_1.cpp"); + mustHave << QLatin1String("sqr"); + mustHave << QLatin1String("~Math"); + unexpected << QLatin1String("operator="); + QTest::newRow("case 1: method call completion") << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); + + file = QLatin1String("cxx_regression_2.cpp"); + unexpected << QLatin1String("i_second"); + unexpected << QLatin1String("c_second"); + unexpected << QLatin1String("f_second"); + mustHave << QLatin1String("i_first"); + mustHave << QLatin1String("c_first"); + QTest::newRow("case 2: multiple anonymous structs") << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); + + file = QLatin1String("cxx_regression_3.cpp"); + mustHave << QLatin1String("i8"); + mustHave << QLatin1String("i64"); + mustHave << QLatin1String("~Priv"); + unexpected << QLatin1String("operator="); + QTest::newRow("case 3: nested class resolution") << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); + + file = QLatin1String("cxx_regression_4.cpp"); + mustHave << QLatin1String("action"); + QTest::newRow("case 4: local (in function) class resolution") << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); + + file = QLatin1String("cxx_regression_5.cpp"); + mustHave << QLatin1String("doB"); + unexpected << QLatin1String("doA"); + QTest::newRow("case 5: nested template class resolution") << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); + + file = QLatin1String("cxx_regression_6.cpp"); + mustHave << QLatin1String("OwningPtr"); + QTest::newRow("case 6: using particular symbol from namespace") << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); + + file = QLatin1String("cxx_regression_7.cpp"); + mustHave << QLatin1String("dataMember"); + mustHave << QLatin1String("anotherMember"); + QTest::newRow("case 7: template class inherited from template parameter") << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); + + file = QLatin1String("cxx_regression_8.cpp"); + mustHave << QLatin1String("utils::"); + unexpected << QLatin1String("utils"); + QTest::newRow("case 8: namespace completion in function body") << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); + + file = QLatin1String("cxx_regression_9.cpp"); + mustHave << QLatin1String("EnumScoped::Value1"); + mustHave << QLatin1String("EnumScoped::Value2"); + mustHave << QLatin1String("EnumScoped::Value3"); + unexpected << QLatin1String("Value1"); + unexpected << QLatin1String("EnumScoped"); + QTest::newRow("case 9: c++11 enum class, value used in switch and 'case' completed") + << file << unexpected << mustHave; + mustHave.clear(); + unexpected.clear(); +} + +void ClangCodeModelPlugin::test_CXX_snippets() +{ + QFETCH(QString, file); + QFETCH(QStringList, texts); + QFETCH(QStringList, snippets); + Q_ASSERT(texts.size() == snippets.size()); + + CompletionTestHelper helper; + helper << file; + + QList<CodeCompletionResult> proposals = helper.codeComplete(); + + for (int i = 0, n = texts.size(); i < n; ++i) { + const QString &text = texts[i]; + const QString &snippet = snippets[i]; + const QString snippetError = + QLatin1String("Text and snippet mismatch: text '") + text + + QLatin1String("', snippet '") + snippet + + QLatin1String("', got snippet '%1'"); + + bool hasText = false; + foreach (const CodeCompletionResult &ccr, proposals) { + if (ccr.text() != text) + continue; + hasText = true; + QVERIFY2(snippet == ccr.snippet(), snippetError.arg(ccr.snippet()).toAscii()); + } + const QString textError(QLatin1String("Text not found:") + text); + QVERIFY2(hasText, textError.toAscii()); + } +} + +void ClangCodeModelPlugin::test_CXX_snippets_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QStringList>("texts"); + QTest::addColumn<QStringList>("snippets"); + + QString file; + QStringList texts; + QStringList snippets; + + file = QLatin1String("cxx_snippets_1.cpp"); + texts << QLatin1String("reinterpret_cast<type>(expression)"); + snippets << QLatin1String("reinterpret_cast<$type$>($expression$)"); + + texts << QLatin1String("static_cast<type>(expression)"); + snippets << QLatin1String("static_cast<$type$>($expression$)"); + + texts << QLatin1String("new type(expressions)"); + snippets << QLatin1String("new $type$($expressions$)"); + + QTest::newRow("case: snippets for var declaration") << file << texts << snippets; + texts.clear(); + snippets.clear(); + + file = QLatin1String("cxx_snippets_2.cpp"); + texts << QLatin1String("private"); + snippets << QLatin1String(""); + + texts << QLatin1String("protected"); + snippets << QLatin1String(""); + + texts << QLatin1String("public"); + snippets << QLatin1String(""); + + texts << QLatin1String("friend"); + snippets << QLatin1String(""); + + texts << QLatin1String("virtual"); + snippets << QLatin1String(""); + + texts << QLatin1String("typedef type name"); + snippets << QLatin1String("typedef $type$ $name$"); + + QTest::newRow("case: snippets inside class declaration") << file << texts << snippets; + texts.clear(); + snippets.clear(); + + file = QLatin1String("cxx_snippets_3.cpp"); + texts << QLatin1String("List"); + snippets << QLatin1String("List<$class Item$>"); + + texts << QLatin1String("Tuple"); + snippets << QLatin1String("Tuple<$class First$, $class Second$, $typename Third$>"); + + QTest::newRow("case: template class insertion as snippet") << file << texts << snippets; + texts.clear(); + snippets.clear(); + + file = QLatin1String("cxx_snippets_4.cpp"); + texts << QLatin1String("clamp"); + snippets << QLatin1String(""); + + texts << QLatin1String("perform"); + snippets << QLatin1String("perform<$class T$>"); + + QTest::newRow("case: template function insertion as snippet") << file << texts << snippets; + texts.clear(); + snippets.clear(); +} + +void ClangCodeModelPlugin::test_ObjC_hints() +{ + QFETCH(QString, file); + QFETCH(QStringList, texts); + QFETCH(QStringList, snippets); + QFETCH(QStringList, hints); + Q_ASSERT(texts.size() == snippets.size()); + Q_ASSERT(texts.size() == hints.size()); + + CompletionTestHelper helper; + helper << file; + + QList<CodeCompletionResult> proposals = helper.codeComplete(); + + for (int i = 0, n = texts.size(); i < n; ++i) { + const QString &text = texts[i]; + const QString &snippet = snippets[i]; + const QString &hint = hints[i]; + const QString snippetError = + QLatin1String("Text and snippet mismatch: text '") + text + + QLatin1String("', snippet '") + snippet + + QLatin1String("', got snippet '%1'"); + const QString hintError = + QLatin1String("Text and hint mismatch: text '") + text + + QLatin1String("', hint\n'") + hint + + QLatin1String(", got hint\n'%1'"); + + bool hasText = false; + QStringList texts; + foreach (const CodeCompletionResult &ccr, proposals) { + texts << ccr.text(); + if (ccr.text() != text) + continue; + hasText = true; + QVERIFY2(snippet == ccr.snippet(), snippetError.arg(ccr.snippet()).toAscii()); + QVERIFY2(hint == ccr.hint(), hintError.arg(ccr.hint()).toAscii()); + } + const QString textError(QString::fromLatin1("Text '%1' not found in set %2") + .arg(text).arg(texts.join(QLatin1Char(',')))); + QVERIFY2(hasText, textError.toAscii()); + } +} + +static QString makeObjCHint(const char *cHintPattern) +{ + QString hintPattern(QString::fromUtf8(cHintPattern)); + QStringList lines = hintPattern.split(QLatin1Char('\n')); + QString hint = QLatin1String("<p>"); + bool prependNewline = false; + foreach (const QString &line, lines) { + if (prependNewline) + hint += QLatin1String("<br/>"); + prependNewline = true; + int i = 0; + while (i < line.size() && line[i] == QLatin1Char(' ')) { + ++i; + hint += QLatin1String(" "); + } + hint += line.mid(i); + } + hint += QLatin1String("</p>"); + return hint; +} + +void ClangCodeModelPlugin::test_ObjC_hints_data() +{ + QTest::addColumn<QString>("file"); + QTest::addColumn<QStringList>("texts"); + QTest::addColumn<QStringList>("snippets"); + QTest::addColumn<QStringList>("hints"); + + QString file; + QStringList texts; + QStringList snippets; + QStringList hints; + + file = QLatin1String("objc_messages_1.mm"); + texts << QLatin1String("spectacleQuality:"); + snippets << QLatin1String("spectacleQuality:$(bool)$"); + hints << makeObjCHint("-(int) spectacleQuality:<b>(bool)</b>"); + texts << QLatin1String("desiredAmountForDramaDose:andPersonsCount:"); + snippets << QLatin1String("desiredAmountForDramaDose:$(int)$ andPersonsCount:$(int)$"); + hints << makeObjCHint("-(int) desiredAmountForDramaDose:<b>(int)</b> \n" + " andPersonsCount:<b>(int)</b>"); + + QTest::newRow("case: objective-c instance messages call") << file << texts << snippets << hints; + texts.clear(); + snippets.clear(); + hints.clear(); + + file = QLatin1String("objc_messages_2.mm"); + texts << QLatin1String("eatenAmount"); + snippets << QLatin1String("(int) eatenAmount"); + hints << makeObjCHint("+(int) eatenAmount"); + texts << QLatin1String("desiredAmountForDramaDose:andPersonsCount:"); + snippets << QLatin1String("(int) desiredAmountForDramaDose:(int)dose andPersonsCount:(int)count"); + hints << makeObjCHint("+(int) desiredAmountForDramaDose:(int)dose \n" + " andPersonsCount:(int)count"); + + QTest::newRow("case: objective-c class messages in @implementation") << file << texts << snippets << hints; + texts.clear(); + snippets.clear(); + hints.clear(); + + file = QLatin1String("objc_messages_3.mm"); + texts << QLatin1String("eatenAmount"); + snippets << QLatin1String("(int) eatenAmount"); + hints << makeObjCHint("-(int) eatenAmount"); + texts << QLatin1String("spectacleQuality"); + snippets << QLatin1String("(int) spectacleQuality"); + hints << makeObjCHint("-(int) spectacleQuality"); + texts << QLatin1String("desiredAmountForDramaDose:andPersonsCount:"); + snippets << QLatin1String("(int) desiredAmountForDramaDose:(int)dose andPersonsCount:(int)count"); + hints << makeObjCHint("-(int) desiredAmountForDramaDose:(int)dose \n" + " andPersonsCount:(int)count"); + texts << QLatin1String("initWithOldTracker:"); + snippets << QLatin1String("(id) initWithOldTracker:(Bbbb<Aaaa> *)aabb"); + hints << makeObjCHint("-(id) initWithOldTracker:(Bbbb<Aaaa> *)aabb"); + + QTest::newRow("case: objective-c class messages from base class") << file << texts << snippets << hints; + texts.clear(); + snippets.clear(); + hints.clear(); +} + +#endif diff --git a/src/plugins/clangcodemodel/test/completiontesthelper.cpp b/src/plugins/clangcodemodel/test/completiontesthelper.cpp new file mode 100644 index 0000000000..f3b4c5c871 --- /dev/null +++ b/src/plugins/clangcodemodel/test/completiontesthelper.cpp @@ -0,0 +1,148 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifdef WITH_TESTS + +#include "completiontesthelper.h" +#include "../clangcompletion.h" +#include "../clangcompleter.h" +#include "../clangcodemodelplugin.h" + +#include <cpptools/cppcompletionassist.h> + +#include <texteditor/basetextdocument.h> +#include <texteditor/plaintexteditor.h> +#include <texteditor/codeassist/iassistproposal.h> +#include <texteditor/codeassist/iassistproposalmodel.h> +#include <texteditor/codeassist/basicproposalitemlistmodel.h> + +#include <utils/fileutils.h> +#include <utils/changeset.h> + +#include <QDir> +#include <QtTest> + +using namespace ClangCodeModel; +using namespace ClangCodeModel::Internal; +using namespace TextEditor; +using namespace CPlusPlus; +using namespace CppTools::Internal; + +namespace ClangCodeModel { +namespace Internal { + +CompletionTestHelper::CompletionTestHelper(QObject *parent) : + QObject(parent), + m_completer(new ClangCompleter()), + m_position(m_line), + m_line(0), + m_column(0) +{ + m_clangOptions << QLatin1String("-std=c++0x") + << QLatin1String("-ObjC++"); +} + +CompletionTestHelper::~CompletionTestHelper() +{ +} + +void CompletionTestHelper::operator <<(const QString &fileName) +{ + QResource res(QLatin1String(":/unittests/ClangCodeModel/") + fileName); + m_sourceCode = QByteArray(reinterpret_cast<const char*>(res.data()), res.size()); + findCompletionPos(); + + QString path = QDir::tempPath() + QLatin1String("/file.h"); + ::Utils::FileSaver srcSaver(path); + srcSaver.write(m_sourceCode); + srcSaver.finalize(); + + m_completer->setFileName(path); + m_completer->setOptions(m_clangOptions); +} + +QStringList CompletionTestHelper::codeCompleteTexts() +{ + QList<CodeCompletionResult> results = + m_completer->codeCompleteAt(m_line, m_column, m_unsavedFiles); + + QStringList completions; + foreach (const CodeCompletionResult& ccr, results) + completions << ccr.text(); + return completions; +} + +QList<CodeCompletionResult> CompletionTestHelper::codeComplete() +{ + return m_completer->codeCompleteAt(m_line, m_column, m_unsavedFiles); +} + +int CompletionTestHelper::position() const +{ + return m_position; +} + +const QByteArray &CompletionTestHelper::source() const +{ + return m_sourceCode; +} + +void CompletionTestHelper::addOption(const QString &option) +{ + m_clangOptions << option; +} + +void CompletionTestHelper::findCompletionPos() +{ + m_position = m_sourceCode.indexOf("<<<<"); + QVERIFY(m_position != -1); + m_sourceCode[m_position] = ' '; + m_sourceCode[m_position + 1] = ' '; + m_sourceCode[m_position + 2] = ' '; + m_sourceCode[m_position + 3] = ' '; + + // substring from 0 to '@' position + QByteArray substr(m_sourceCode.data(), m_position); + + m_line = 1; + m_column = 1; + for (int i = 0; i < substr.size(); ++i) { + if (substr[i] == '\n') { + ++m_line; + m_column = 1; + } else { + ++m_column; + } + } +} + +} // namespace Internal +} // namespace ClangCodeModel + +#endif diff --git a/src/plugins/clangcodemodel/test/completiontesthelper.h b/src/plugins/clangcodemodel/test/completiontesthelper.h new file mode 100644 index 0000000000..95418b2c95 --- /dev/null +++ b/src/plugins/clangcodemodel/test/completiontesthelper.h @@ -0,0 +1,80 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef CLANGCODEMODEL_TESTS_COMPLETIONTESTHELPER_H +#define CLANGCODEMODEL_TESTS_COMPLETIONTESTHELPER_H + +#ifdef WITH_TESTS + +#include <QObject> +#include <QTextDocument> +#include <texteditor/basetexteditor.h> +#include <cplusplus/CppDocument.h> +#include <clangcompleter.h> + +namespace TextEditor { class IAssistProposal; } + +namespace ClangCodeModel { +namespace Internal { + +class CompletionTestHelper : public QObject +{ + Q_OBJECT +public: + explicit CompletionTestHelper(QObject *parent = 0); + ~CompletionTestHelper(); + + void operator <<(const QString &fileName); + QStringList codeCompleteTexts(); + QList<CodeCompletionResult> codeComplete(); + + int position() const; + const QByteArray &source() const; + + void addOption(const QString &option); + +private: + void findCompletionPos(); + + UnsavedFiles m_unsavedFiles; + ClangCompleter::Ptr m_completer; + QStringList m_clangOptions; + + QByteArray m_sourceCode; + int m_position; + int m_line; + int m_column; +}; + +} // namespace Internal +} // namespace ClangCodeModel + +#endif + +#endif // CLANGCODEMODEL_TESTS_COMPLETIONTESTHELPER_H diff --git a/src/plugins/clangcodemodel/test/cxx_regression_1.cpp b/src/plugins/clangcodemodel/test/cxx_regression_1.cpp new file mode 100644 index 0000000000..15ae3540e9 --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_1.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'sqr' + * Not expected: '~Math', 'operator='s + */ + +class Math +{ + int sqr(int a); +}; + +void foo() +{ + Math math; + int sqr = math.<<<<; +} diff --git a/src/plugins/clangcodemodel/test/cxx_regression_2.cpp b/src/plugins/clangcodemodel/test/cxx_regression_2.cpp new file mode 100644 index 0000000000..e342bde00a --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_2.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'i_first' 'c_first' + * Not expected: 'i_second' 'c_second' 'f_second' + */ + +typedef struct { + int i_first; + char c_first; +} S1; + +typedef struct { + int i_second; + char c_second; + float f_second; +} S2; + +void foo() +{ + S1 s; + s.<<<<; +} diff --git a/src/plugins/clangcodemodel/test/cxx_regression_3.cpp b/src/plugins/clangcodemodel/test/cxx_regression_3.cpp new file mode 100644 index 0000000000..a1fd800998 --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_3.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'i8' 'i64' + * Unexpected: 'Priv' 'operator=' + */ + +class Example +{ +public: + Example(); + ~Example(); + +private: + class Priv; + Priv *d; +}; + +class Example::Priv +{ +public: + int i8; + int i64; + + Priv() : i8(8), i64(64) {} +}; + +Example::Example() + : d(new Example::Priv()) +{ + d-><<<<; +} + +Example::~Example() +{ +} + +void f() +{ + Example w; +} diff --git a/src/plugins/clangcodemodel/test/cxx_regression_4.cpp b/src/plugins/clangcodemodel/test/cxx_regression_4.cpp new file mode 100644 index 0000000000..ac18460891 --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_4.cpp @@ -0,0 +1,41 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'action' + */ + +void func() +{ + struct impl + { + static void action() {} + }; + impl::<<<<; +} diff --git a/src/plugins/clangcodemodel/test/cxx_regression_5.cpp b/src/plugins/clangcodemodel/test/cxx_regression_5.cpp new file mode 100644 index 0000000000..b5ab3e362f --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_5.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'doB' + * Not expected: 'doA' + */ + +struct A { + struct Inside { + void doA() {} + }; +}; + +struct B { + struct Inside { + void doB() {} + }; +}; + +template<class T> class C { +public: + typename T::Inside inner; +}; + +int main() +{ + C<A> ca; + C<B> cb; + ca.inner.doA(); + cb.inner.<<<<; + + return 0; +} + diff --git a/src/plugins/clangcodemodel/test/cxx_regression_6.cpp b/src/plugins/clangcodemodel/test/cxx_regression_6.cpp new file mode 100644 index 0000000000..81f5ce78a5 --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_6.cpp @@ -0,0 +1,50 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'OwningPtr' + */ + +namespace llvm { +class OwningPtr; +} + +namespace clang { +using llvm::OwningPtr; +} + +class llvm::OwningPtr +{ +}; + +void foo() +{ + clang::<<<< ptr; + (void)ptr; +} diff --git a/src/plugins/clangcodemodel/test/cxx_regression_7.cpp b/src/plugins/clangcodemodel/test/cxx_regression_7.cpp new file mode 100644 index 0000000000..5e9b9095d5 --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_7.cpp @@ -0,0 +1,47 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'dataMember', 'anotherMember' + */ + +class Data { + int dataMember; +}; + +template <class T> class Other : public T +{ + int anotherMember; +}; + +void func() +{ + Other<Data> c; + c.<<<<; +} diff --git a/src/plugins/clangcodemodel/test/cxx_regression_8.cpp b/src/plugins/clangcodemodel/test/cxx_regression_8.cpp new file mode 100644 index 0000000000..6305c5c76c --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_8.cpp @@ -0,0 +1,46 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'utils::' + * Not expected: 'utils' + */ + +namespace utils +{ +int sqr(int a) +{ + return a * a; +} +} + +void foo() +{ + <<<< +} diff --git a/src/plugins/clangcodemodel/test/cxx_regression_9.cpp b/src/plugins/clangcodemodel/test/cxx_regression_9.cpp new file mode 100644 index 0000000000..59a77646ec --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_regression_9.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected: 'EnumScoped::Value1', 'EnumScoped::Value2', 'EnumScoped::Value3' + * Unexpected: 'Value1' + */ + +enum class EnumScoped +{ + Value1, + Value2, + Value3 +}; + +class ClassOwnsEnum +{ +}; + +int main() +{ + EnumScoped scoped = ; + switch (scoped) { + default: + break; + case <<<< + } +} diff --git a/src/plugins/clangcodemodel/test/cxx_snippets_1.cpp b/src/plugins/clangcodemodel/test/cxx_snippets_1.cpp new file mode 100644 index 0000000000..2d0bfc390b --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_snippets_1.cpp @@ -0,0 +1,48 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + Expected: + text 'reinterpret_cast<type>(expression)' + snippet 'reinterpret_cast<$type$>($expression$)' + + text 'static_cast<type>(expression)' + snippet 'static_cast<$type$>($expression$)' + + text 'new type(expressions)' + snippet 'new $type$($expressions$)' + */ + +void foo() +{ + int data[] = { + 1, 2, 3 + }; + char *cdata = <<<<; +} diff --git a/src/plugins/clangcodemodel/test/cxx_snippets_2.cpp b/src/plugins/clangcodemodel/test/cxx_snippets_2.cpp new file mode 100644 index 0000000000..1d4853df94 --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_snippets_2.cpp @@ -0,0 +1,44 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + Expected: + text 'private', + text 'protected', + text 'public', + text 'friend', + text 'virtual' + + text 'typedef type name', snippet 'typedef $type$ $name$' + */ + +class A +{ + <<<< +}; diff --git a/src/plugins/clangcodemodel/test/cxx_snippets_3.cpp b/src/plugins/clangcodemodel/test/cxx_snippets_3.cpp new file mode 100644 index 0000000000..6258c49c65 --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_snippets_3.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +// Expected: +// (List, List<$class Item$>), +// (Tuple, Tuple<$class First$, $class Second$, $typename Third$>) + +template <class Item> +class List +{ + Item *data; +}; + +template <class First, class Second, typename Third> +class Tuple +{ + First *data; + Second *data2; + Third *data3; +}; + +void check() +{ + <<<< +} + diff --git a/src/plugins/clangcodemodel/test/cxx_snippets_4.cpp b/src/plugins/clangcodemodel/test/cxx_snippets_4.cpp new file mode 100644 index 0000000000..e4bd99fe74 --- /dev/null +++ b/src/plugins/clangcodemodel/test/cxx_snippets_4.cpp @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +// Expected: +// (clamp, ), +// (perform, perform<$class T$>) +// (perform3, perform3<$class T$, $int E$, $class D$>) + +// note: clang understands if parameter is redundant + +template<class T> +T clamp(T value, T a = 0.0, T b = 1.0) +{ + if (value < a) + return a; + if (value > b) + return b; + return value; +} + +template<class T> +void perform() +{ +} + +template<class T, int E, class D> +void perform3() +{ +} + +void check() +{ + <<<< +} diff --git a/src/plugins/clangcodemodel/test/objc_messages_1.mm b/src/plugins/clangcodemodel/test/objc_messages_1.mm new file mode 100644 index 0000000000..f64f4e985f --- /dev/null +++ b/src/plugins/clangcodemodel/test/objc_messages_1.mm @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +/* + * Expected texts: + * eatenAmount + * spectacleQuality: + * desiredAmountForDramaDose:andPersonsCount: + * + * Expected hints: + * -(int) eatenAmount + * + * -(int) spectacleQuality:(bool)unused + */ + +@interface PopCornTracker { + int _quality; + int _eatenAmount; + int _remainedAmount; +} ++ (int) eatenAmount; +- (int) spectacleQuality : (bool)unused; +- (int) desiredAmountForDramaDose: (int)dose andPersonsCount: (int) count; +@end + +@implementation PopCornTracker +- (int) desiredAmountForDramaDose: (int)dose andPersonsCount: (int) count +{ + [self <<<<]; +} +@end diff --git a/src/plugins/clangcodemodel/test/objc_messages_2.mm b/src/plugins/clangcodemodel/test/objc_messages_2.mm new file mode 100644 index 0000000000..f534e0aa88 --- /dev/null +++ b/src/plugins/clangcodemodel/test/objc_messages_2.mm @@ -0,0 +1,42 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +@interface PopCornTracker { + int _quality; + int _eatenAmount; + int _remainedAmount; +} ++ (int) eatenAmount; +- (int) spectacleQuality; ++ (int) desiredAmountForDramaDose: (int)dose andPersonsCount: (int) count; +@end + +@implementation PopCornTracker ++ <<<< +@end diff --git a/src/plugins/clangcodemodel/test/objc_messages_3.mm b/src/plugins/clangcodemodel/test/objc_messages_3.mm new file mode 100644 index 0000000000..8231b2fe8b --- /dev/null +++ b/src/plugins/clangcodemodel/test/objc_messages_3.mm @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of Qt Creator. +** +** 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. +** +** GNU Lesser General Public License Usage +** 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 +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +@protocol Aaaa +@end + +@interface Bbbb +@end + +@interface PopCornTracker { + int _quality; + int _eatenAmount; + int _remainedAmount; +} +- (int) eatenAmount; +- (int) spectacleQuality; +- (int) desiredAmountForDramaDose: (int)dose andPersonsCount: (int) count; ++ (id) createNewTracker; ++ (id) createOldTracker:(Bbbb<Aaaa> *) aabb; +- (id) initWithOldTracker:(Bbbb<Aaaa> *) aabb; +@end + +@interface AdvancedPopCornTracker : PopCornTracker { +} + +- <<<< + +@end |