diff options
author | Eike Ziller <eike.ziller@qt.io> | 2017-07-18 15:23:29 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2017-07-18 15:23:29 +0200 |
commit | 361fdad3be3421496be4dab014a8bee369687387 (patch) | |
tree | 4412737d90b20953064b8f53817c014ddc9714c3 /src/libs | |
parent | 5e38bdbfd8bef6c3bdcede9fe0be11f34e9a0f7c (diff) | |
parent | 41ae823bda7cc1bad4b85861d9b0e3087c130e4a (diff) |
Merge remote-tracking branch 'origin/4.4'
Change-Id: I778acc044ac105a11054b314aecac5b1c2cfee6a
Diffstat (limited to 'src/libs')
-rw-r--r-- | src/libs/3rdparty/cplusplus/Parser.cpp | 4 | ||||
-rw-r--r-- | src/libs/cplusplus/MatchingText.cpp | 6 | ||||
-rw-r--r-- | src/libs/utils/qtcfallthrough.h | 54 | ||||
-rw-r--r-- | src/libs/utils/utils-lib.pri | 1 | ||||
-rw-r--r-- | src/libs/utils/utils.qbs | 1 |
5 files changed, 64 insertions, 2 deletions
diff --git a/src/libs/3rdparty/cplusplus/Parser.cpp b/src/libs/3rdparty/cplusplus/Parser.cpp index 8754206a0b..16f351077a 100644 --- a/src/libs/3rdparty/cplusplus/Parser.cpp +++ b/src/libs/3rdparty/cplusplus/Parser.cpp @@ -27,6 +27,8 @@ #include "ObjectiveCTypeQualifiers.h" #include "QtContextKeywords.h" +#include <utils/qtcfallthrough.h> + #include <unordered_map> #include <utility> @@ -442,7 +444,7 @@ bool Parser::skipUntilStatement() case T_AT_THROW: if (_languageFeatures.objCEnabled) return true; - + Q_FALLTHROUGH(); default: consumeToken(); } diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index f783d4c508..3fdb573b91 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -143,9 +143,13 @@ bool MatchingText::contextAllowsAutoParentheses(const QTextCursor &cursor, if (!textToInsert.isEmpty()) ch = textToInsert.at(0); + if (ch == QLatin1Char('{') && cursor.block().text().trimmed().isEmpty()) + return false; // User just might want to wrap up some lines. + if (!shouldInsertMatchingText(cursor) && ch != QLatin1Char('\'') && ch != QLatin1Char('"')) return false; - else if (isInCommentHelper(cursor)) + + if (isInCommentHelper(cursor)) return false; return true; diff --git a/src/libs/utils/qtcfallthrough.h b/src/libs/utils/qtcfallthrough.h new file mode 100644 index 0000000000..6eba622837 --- /dev/null +++ b/src/libs/utils/qtcfallthrough.h @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** 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 The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include <QtGlobal> + +#ifndef Q_FALLTHROUGH +#ifndef QT_HAS_CPP_ATTRIBUTE +#ifdef __has_cpp_attribute +# define QT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x) +#else +# define QT_HAS_CPP_ATTRIBUTE(x) 0 +#endif +#endif +#if defined(__cplusplus) +#if QT_HAS_CPP_ATTRIBUTE(fallthrough) +# define Q_FALLTHROUGH() [[fallthrough]] +#elif QT_HAS_CPP_ATTRIBUTE(clang::fallthrough) +# define Q_FALLTHROUGH() [[clang::fallthrough]] +#elif QT_HAS_CPP_ATTRIBUTE(gnu::fallthrough) +# define Q_FALLTHROUGH() [[gnu::fallthrough]] +#endif +#endif +#ifndef Q_FALLTHROUGH +# if (defined(Q_CC_GNU) && Q_CC_GNU >= 700) && !defined(Q_CC_INTEL) +# define Q_FALLTHROUGH() __attribute__((fallthrough)) +# else +# define Q_FALLTHROUGH() (void)0 +#endif +#endif +#endif diff --git a/src/libs/utils/utils-lib.pri b/src/libs/utils/utils-lib.pri index bfc9d6084e..3a6aa0a09a 100644 --- a/src/libs/utils/utils-lib.pri +++ b/src/libs/utils/utils-lib.pri @@ -239,6 +239,7 @@ HEADERS += \ $$PWD/asconst.h \ $$PWD/smallstringfwd.h \ $$PWD/optional.h \ + $$PWD/qtcfallthrough.h \ $$PWD/../3rdparty/optional/optional.hpp FORMS += $$PWD/filewizardpage.ui \ diff --git a/src/libs/utils/utils.qbs b/src/libs/utils/utils.qbs index 559129df16..6d68683fdd 100644 --- a/src/libs/utils/utils.qbs +++ b/src/libs/utils/utils.qbs @@ -175,6 +175,7 @@ Project { "proxycredentialsdialog.cpp", "proxycredentialsdialog.h", "proxycredentialsdialog.ui", + "qtcfallthrough.h", "qtcassert.cpp", "qtcassert.h", "qtcolorbutton.cpp", |