[C++] Added object pool handling for CompletionAssistProvider.

Change-Id: I89634989a7f360a30f7ed1bde4e67c93551ddfe4
Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
This commit is contained in:
Erik Verbruggen
2012-02-21 10:00:32 +01:00
parent f3a3bf78c0
commit 2d262bd3b7
13 changed files with 212 additions and 286 deletions

View File

@@ -0,0 +1,108 @@
#include "cppcompletionassistprovider.h"
#include <cppeditor/cppeditorconstants.h>
#include <Token.h>
using namespace CPlusPlus;
using namespace CppTools;
// ---------------------------
// CppCompletionAssistProvider
// ---------------------------
bool CppCompletionAssistProvider::supportsEditor(const Core::Id &editorId) const
{
return editorId == Core::Id(CppEditor::Constants::CPPEDITOR_ID);
}
int CppCompletionAssistProvider::activationCharSequenceLength() const
{
return 3;
}
bool CppCompletionAssistProvider::isActivationCharSequence(const QString &sequence) const
{
const QChar &ch = sequence.at(2);
const QChar &ch2 = sequence.at(1);
const QChar &ch3 = sequence.at(0);
if (activationSequenceChar(ch, ch2, ch3, 0, true) != 0)
return true;
return false;
}
int CppCompletionAssistProvider::activationSequenceChar(const QChar &ch,
const QChar &ch2,
const QChar &ch3,
unsigned *kind,
bool wantFunctionCall)
{
int referencePosition = 0;
int completionKind = T_EOF_SYMBOL;
switch (ch.toLatin1()) {
case '.':
if (ch2 != QLatin1Char('.')) {
completionKind = T_DOT;
referencePosition = 1;
}
break;
case ',':
completionKind = T_COMMA;
referencePosition = 1;
break;
case '(':
if (wantFunctionCall) {
completionKind = T_LPAREN;
referencePosition = 1;
}
break;
case ':':
if (ch3 != QLatin1Char(':') && ch2 == QLatin1Char(':')) {
completionKind = T_COLON_COLON;
referencePosition = 2;
}
break;
case '>':
if (ch2 == QLatin1Char('-')) {
completionKind = T_ARROW;
referencePosition = 2;
}
break;
case '*':
if (ch2 == QLatin1Char('.')) {
completionKind = T_DOT_STAR;
referencePosition = 2;
} else if (ch3 == QLatin1Char('-') && ch2 == QLatin1Char('>')) {
completionKind = T_ARROW_STAR;
referencePosition = 3;
}
break;
case '\\':
case '@':
if (ch2.isNull() || ch2.isSpace()) {
completionKind = T_DOXY_COMMENT;
referencePosition = 1;
}
break;
case '<':
completionKind = T_ANGLE_STRING_LITERAL;
referencePosition = 1;
break;
case '"':
completionKind = T_STRING_LITERAL;
referencePosition = 1;
break;
case '/':
completionKind = T_SLASH;
referencePosition = 1;
break;
case '#':
completionKind = T_POUND;
referencePosition = 1;
break;
}
if (kind)
*kind = completionKind;
return referencePosition;
}