aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/clangcodemodel/clangactivationsequenceprocessor.cpp
diff options
context:
space:
mode:
authorNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-11-30 09:43:50 +0100
committerNikolai Kosjar <nikolai.kosjar@theqtcompany.com>2015-11-30 11:04:07 +0000
commit1410bf3faf222d79b6789add5bd2b759d1abf22a (patch)
tree201f587003c76267362b26d2f30ce6110cf93c17 /src/plugins/clangcodemodel/clangactivationsequenceprocessor.cpp
parent6a393afeda21401013fe89c061fec5cac7a811b2 (diff)
Clang: Use "clang" prefix plugin files
...for consistency and to avoid future file name clashes. Change-Id: If595c8debfa1ceb01a1bb0ed34649fa513660503 Reviewed-by: Marco Bubke <marco.bubke@theqtcompany.com>
Diffstat (limited to 'src/plugins/clangcodemodel/clangactivationsequenceprocessor.cpp')
-rw-r--r--src/plugins/clangcodemodel/clangactivationsequenceprocessor.cpp208
1 files changed, 208 insertions, 0 deletions
diff --git a/src/plugins/clangcodemodel/clangactivationsequenceprocessor.cpp b/src/plugins/clangcodemodel/clangactivationsequenceprocessor.cpp
new file mode 100644
index 00000000000..08f97558e7f
--- /dev/null
+++ b/src/plugins/clangcodemodel/clangactivationsequenceprocessor.cpp
@@ -0,0 +1,208 @@
+/****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://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 http://www.qt.io/terms-conditions. For further information
+** use the contact form at http://www.qt.io/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 or version 3 as published by the Free
+** Software Foundation and appearing in the file LICENSE.LGPLv21 and
+** LICENSE.LGPLv3 included in the packaging of this file. Please review the
+** following information to ensure the GNU Lesser General Public License
+** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, The Qt Company gives you certain additional
+** rights. These rights are described in The Qt Company LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+****************************************************************************/
+
+#include "clangactivationsequenceprocessor.h"
+
+namespace ClangCodeModel {
+namespace Internal {
+
+namespace {
+
+QString truncateActivationStringByPosition(const QString &activationString,
+ int positionInDocument)
+{
+ if (positionInDocument == 1)
+ return activationString.left(1);
+
+ if (positionInDocument == 2)
+ return activationString.left(2);
+
+ return activationString;
+}
+
+}
+
+ActivationSequenceProcessor::ActivationSequenceProcessor(const QString &activationString,
+ int positionInDocument,
+ bool wantFunctionCall)
+ : m_positionInDocument(positionInDocument),
+ m_wantFunctionCall(wantFunctionCall)
+{
+ extractCharactersBeforePosition(truncateActivationStringByPosition(activationString,
+ positionInDocument));
+
+ process();
+}
+
+CPlusPlus::Kind ActivationSequenceProcessor::completionKind() const
+{
+ return m_completionKind;
+}
+
+int ActivationSequenceProcessor::offset() const
+{
+ return m_offset;
+}
+
+int ActivationSequenceProcessor::operatorStartPosition() const
+{
+ return m_positionInDocument - m_offset;
+}
+
+void ActivationSequenceProcessor::extractCharactersBeforePosition(const QString &activationString)
+{
+ if (activationString.size() >= 3) {
+ m_char1 = activationString[0];
+ m_char2 = activationString[1];
+ m_char3 = activationString[2];
+ } else if (activationString.size() == 2) {
+ m_char2 = activationString[0];
+ m_char3 = activationString[1];
+ } else if (activationString.size() == 1) {
+ m_char3 = activationString[0];
+ }
+}
+
+void ActivationSequenceProcessor::process()
+{
+ processDot();
+ processComma();
+ processLeftParen();
+ processColonColon();
+ processArrow();
+ processDotStar();
+ processArrowStar();
+ processDoxyGenComment();
+ processAngleStringLiteral();
+ processStringLiteral();
+ processSlash();
+ processPound();
+}
+
+void ActivationSequenceProcessor::processDot()
+{
+ if (m_char3 == QLatin1Char('.') && m_char2 != QLatin1Char('.')) {
+ m_completionKind = CPlusPlus::T_DOT;
+ m_offset = 1;
+ }
+}
+
+void ActivationSequenceProcessor::processComma()
+{
+ if (m_char3 == QLatin1Char(',') ) {
+ m_completionKind = CPlusPlus::T_COMMA;
+ m_offset = 1;
+ }
+}
+
+void ActivationSequenceProcessor::processLeftParen()
+{
+ if (m_char3 == QLatin1Char('(') && m_wantFunctionCall) {
+ m_completionKind = CPlusPlus::T_LPAREN;
+ m_offset = 1;
+ }
+}
+
+void ActivationSequenceProcessor::processColonColon()
+{
+ if (m_char2 == QLatin1Char(':') && m_char3 == QLatin1Char(':')) {
+ m_completionKind = CPlusPlus::T_COLON_COLON;
+ m_offset = 2;
+ }
+}
+
+void ActivationSequenceProcessor::processArrow()
+{
+ if (m_char2 == QLatin1Char('-') && m_char3 == QLatin1Char('>')) {
+ m_completionKind = CPlusPlus::T_ARROW;
+ m_offset = 2;
+ }
+}
+
+void ActivationSequenceProcessor::processDotStar()
+{
+ if (m_char2 == QLatin1Char('.') && m_char3 == QLatin1Char('*')) {
+ m_completionKind = CPlusPlus::T_DOT_STAR;
+ m_offset = 2;
+ }
+}
+
+void ActivationSequenceProcessor::processArrowStar()
+{
+ if (m_char1 == QLatin1Char('-') && m_char2 == QLatin1Char('>') && m_char3 == QLatin1Char('*')) {
+ m_completionKind = CPlusPlus::T_ARROW_STAR;
+ m_offset = 3;
+ }
+}
+
+void ActivationSequenceProcessor::processDoxyGenComment()
+{
+ if ((m_char2.isNull() || m_char2.isSpace())
+ && (m_char3 == QLatin1Char('\\') || m_char3 == QLatin1Char('@'))) {
+ m_completionKind = CPlusPlus::T_DOXY_COMMENT;
+ m_offset = 1;
+ }
+}
+
+void ActivationSequenceProcessor::processAngleStringLiteral()
+{
+ if (m_char3 == QLatin1Char('<')) {
+ m_completionKind = CPlusPlus::T_ANGLE_STRING_LITERAL;
+ m_offset = 1;
+ }
+}
+
+void ActivationSequenceProcessor::processStringLiteral()
+{
+ if (m_char3 == QLatin1Char('"')) {
+ m_completionKind = CPlusPlus::T_STRING_LITERAL;
+ m_offset = 1;
+ }
+}
+
+void ActivationSequenceProcessor::processSlash()
+{
+ if (m_char3 == QLatin1Char('/')) {
+ m_completionKind = CPlusPlus::T_SLASH;
+ m_offset = 1;
+ }
+}
+
+void ActivationSequenceProcessor::processPound()
+{
+ if (m_char3 == QLatin1Char('#')) {
+ m_completionKind = CPlusPlus::T_POUND;
+ m_offset = 1;
+ }
+}
+
+} // namespace Internal
+} // namespace ClangCodeModel
+