From f878da0ea8be0563abb49af9cd7ea58c0063d830 Mon Sep 17 00:00:00 2001
From: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
Date: Wed, 22 Apr 2015 12:56:02 +0200
Subject: [PATCH] CppTools: Offer "override" and "final" as completion items

These are special identifiers and were thus not included in the 'add all
keywords' handling.

Change-Id: I7f65df5711193e945bfa955dcb70a6ab454606b5
Task-number: QTCREATORBUG-11341
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
---
 src/plugins/cpptools/cppcompletion_test.cpp  | 2 ++
 src/plugins/cpptools/cppcompletionassist.cpp | 6 ++++++
 2 files changed, 8 insertions(+)

diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index baa0f784d73..a035c6425f6 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -168,6 +168,8 @@ bool isProbablyGlobalCompletion(const QStringList &list)
             + (T_FIRST_OBJC_AT_KEYWORD - T_FIRST_KEYWORD);
 
     return list.size() >= numberOfPrimitivesAndBasicKeywords
+        && list.contains(QLatin1String("override"))
+        && list.contains(QLatin1String("final"))
         && list.contains(QLatin1String("if"))
         && list.contains(QLatin1String("bool"));
 }
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index b6fd792f73d..daa0af12a47 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -1937,6 +1937,12 @@ void InternalCppCompletionAssistProcessor::addKeywords()
     // primitive type completion items.
     for (int i = T_FIRST_PRIMITIVE; i <= T_LAST_PRIMITIVE; ++i)
         addCompletionItem(QLatin1String(Token::name(i)), m_icons.keywordIcon(), KeywordsOrder);
+
+    // "Identifiers with special meaning"
+    if (m_interface->languageFeatures().cxx11Enabled) {
+        addCompletionItem(QLatin1String("override"), m_icons.keywordIcon(), KeywordsOrder);
+        addCompletionItem(QLatin1String("final"), m_icons.keywordIcon(), KeywordsOrder);
+    }
 }
 
 void InternalCppCompletionAssistProcessor::addMacros(const QString &fileName,
-- 
GitLab