CppTools: Rename CppCompletionAssistProcessor to InternalCpp...

We will introduce a base class with the name
CppCompletionAssistProcessor.

Change-Id: I74a39d0b14d4ee30d7bd7675ad968e83f377de7f
Reviewed-by: Erik Verbruggen <erik.verbruggen@theqtcompany.com>
This commit is contained in:
Nikolai Kosjar
2015-01-16 10:35:23 +01:00
parent 01699e9f25
commit 6d22df7d3f
3 changed files with 58 additions and 51 deletions

View File

@@ -109,7 +109,7 @@ public:
m_editorWidget->document(), m_position, m_editorWidget->document(), m_position,
ExplicitlyInvoked, m_snapshot, ExplicitlyInvoked, m_snapshot,
ProjectPart::HeaderPaths()); ProjectPart::HeaderPaths());
CppCompletionAssistProcessor processor; InternalCppCompletionAssistProcessor processor;
const Tests::IAssistProposalScopedPointer proposal(processor.perform(ai)); const Tests::IAssistProposalScopedPointer proposal(processor.perform(ai));
if (!proposal.d) if (!proposal.d)

View File

@@ -413,7 +413,7 @@ int CppFunctionHintModel::activeArgument(const QString &prefix) const
IAssistProcessor *InternalCompletionAssistProvider::createProcessor() const IAssistProcessor *InternalCompletionAssistProvider::createProcessor() const
{ {
return new CppCompletionAssistProcessor; return new InternalCppCompletionAssistProcessor;
} }
AssistInterface *InternalCompletionAssistProvider::createAssistInterface( AssistInterface *InternalCompletionAssistProvider::createAssistInterface(
@@ -598,10 +598,10 @@ bool isQPrivateSignal(const Symbol *symbol)
} // Anonymous } // Anonymous
// ---------------------------- // ------------------------------------
// CppCompletionAssistProcessor // InternalCppCompletionAssistProcessor
// ---------------------------- // ------------------------------------
CppCompletionAssistProcessor::CppCompletionAssistProcessor() InternalCppCompletionAssistProcessor::InternalCppCompletionAssistProcessor()
: m_startPosition(-1) : m_startPosition(-1)
, m_snippetCollector(QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID), , m_snippetCollector(QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID),
QIcon(QLatin1String(":/texteditor/images/snippet.png"))) QIcon(QLatin1String(":/texteditor/images/snippet.png")))
@@ -628,10 +628,10 @@ CppCompletionAssistProcessor::CppCompletionAssistProcessor()
m_languageFeatures.qtMocRunEnabled = true; m_languageFeatures.qtMocRunEnabled = true;
} }
CppCompletionAssistProcessor::~CppCompletionAssistProcessor() InternalCppCompletionAssistProcessor::~InternalCppCompletionAssistProcessor()
{} {}
IAssistProposal * CppCompletionAssistProcessor::perform(const AssistInterface *interface) IAssistProposal * InternalCppCompletionAssistProcessor::perform(const AssistInterface *interface)
{ {
m_interface.reset(static_cast<const CppCompletionAssistInterface *>(interface)); m_interface.reset(static_cast<const CppCompletionAssistInterface *>(interface));
@@ -649,7 +649,7 @@ IAssistProposal * CppCompletionAssistProcessor::perform(const AssistInterface *i
return 0; return 0;
} }
bool CppCompletionAssistProcessor::accepts() const bool InternalCppCompletionAssistProcessor::accepts() const
{ {
const int pos = m_interface->position(); const int pos = m_interface->position();
unsigned token = T_EOF_SYMBOL; unsigned token = T_EOF_SYMBOL;
@@ -715,7 +715,7 @@ bool CppCompletionAssistProcessor::accepts() const
return false; return false;
} }
IAssistProposal *CppCompletionAssistProcessor::createContentProposal() IAssistProposal *InternalCppCompletionAssistProcessor::createContentProposal()
{ {
// Duplicates are kept only if they are snippets. // Duplicates are kept only if they are snippets.
QSet<QString> processed; QSet<QString> processed;
@@ -745,7 +745,7 @@ IAssistProposal *CppCompletionAssistProcessor::createContentProposal()
return new CppAssistProposal(m_startPosition, m_model.take()); return new CppAssistProposal(m_startPosition, m_model.take());
} }
IAssistProposal *CppCompletionAssistProcessor::createHintProposal( IAssistProposal *InternalCppCompletionAssistProcessor::createHintProposal(
QList<CPlusPlus::Function *> functionSymbols) const QList<CPlusPlus::Function *> functionSymbols) const
{ {
IFunctionHintProposalModel *model = IFunctionHintProposalModel *model =
@@ -754,9 +754,9 @@ IAssistProposal *CppCompletionAssistProcessor::createHintProposal(
return proposal; return proposal;
} }
int CppCompletionAssistProcessor::startOfOperator(int pos, int InternalCppCompletionAssistProcessor::startOfOperator(int pos,
unsigned *kind, unsigned *kind,
bool wantFunctionCall) const bool wantFunctionCall) const
{ {
const QChar ch = pos > -1 ? m_interface->characterAt(pos - 1) : QChar(); const QChar ch = pos > -1 ? m_interface->characterAt(pos - 1) : QChar();
const QChar ch2 = pos > 0 ? m_interface->characterAt(pos - 2) : QChar(); const QChar ch2 = pos > 0 ? m_interface->characterAt(pos - 2) : QChar();
@@ -862,7 +862,7 @@ int CppCompletionAssistProcessor::startOfOperator(int pos,
return start; return start;
} }
int CppCompletionAssistProcessor::findStartOfName(int pos) const int InternalCppCompletionAssistProcessor::findStartOfName(int pos) const
{ {
if (pos == -1) if (pos == -1)
pos = m_interface->position(); pos = m_interface->position();
@@ -876,7 +876,7 @@ int CppCompletionAssistProcessor::findStartOfName(int pos) const
return pos + 1; return pos + 1;
} }
int CppCompletionAssistProcessor::startCompletionHelper() int InternalCppCompletionAssistProcessor::startCompletionHelper()
{ {
if (m_languageFeatures.objCEnabled) { if (m_languageFeatures.objCEnabled) {
if (tryObjCCompletion()) if (tryObjCCompletion())
@@ -970,7 +970,7 @@ int CppCompletionAssistProcessor::startCompletionHelper()
return startCompletionInternal(fileName, line, column, expression, endOfExpression); return startCompletionInternal(fileName, line, column, expression, endOfExpression);
} }
bool CppCompletionAssistProcessor::tryObjCCompletion() bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
{ {
int end = m_interface->position(); int end = m_interface->position();
while (m_interface->characterAt(end).isSpace()) while (m_interface->characterAt(end).isSpace())
@@ -1042,10 +1042,10 @@ enum CompletionOrder {
}; };
} }
void CppCompletionAssistProcessor::addCompletionItem(const QString &text, void InternalCppCompletionAssistProcessor::addCompletionItem(const QString &text,
const QIcon &icon, const QIcon &icon,
int order, int order,
const QVariant &data) const QVariant &data)
{ {
AssistProposalItem *item = new CppAssistProposalItem; AssistProposalItem *item = new CppAssistProposalItem;
item->setText(text); item->setText(text);
@@ -1055,8 +1055,8 @@ void CppCompletionAssistProcessor::addCompletionItem(const QString &text,
m_completions.append(item); m_completions.append(item);
} }
void CppCompletionAssistProcessor::addCompletionItem(CPlusPlus::Symbol *symbol, void InternalCppCompletionAssistProcessor::addCompletionItem(CPlusPlus::Symbol *symbol,
int order) int order)
{ {
ConvertToCompletionItem toCompletionItem; ConvertToCompletionItem toCompletionItem;
AssistProposalItem *item = toCompletionItem(symbol); AssistProposalItem *item = toCompletionItem(symbol);
@@ -1067,8 +1067,8 @@ void CppCompletionAssistProcessor::addCompletionItem(CPlusPlus::Symbol *symbol,
} }
} }
void CppCompletionAssistProcessor::completeObjCMsgSend(CPlusPlus::ClassOrNamespace *binding, void InternalCppCompletionAssistProcessor::completeObjCMsgSend(CPlusPlus::ClassOrNamespace *binding,
bool staticClassAccess) bool staticClassAccess)
{ {
QList<Scope*> memberScopes; QList<Scope*> memberScopes;
foreach (Symbol *s, binding->symbols()) { foreach (Symbol *s, binding->symbols()) {
@@ -1114,7 +1114,7 @@ void CppCompletionAssistProcessor::completeObjCMsgSend(CPlusPlus::ClassOrNamespa
} }
} }
bool CppCompletionAssistProcessor::completeInclude(const QTextCursor &cursor) bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
{ {
QString directoryPrefix; QString directoryPrefix;
if (m_model->m_completionOperator == T_SLASH) { if (m_model->m_completionOperator == T_SLASH) {
@@ -1157,8 +1157,8 @@ bool CppCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
return !m_completions.isEmpty(); return !m_completions.isEmpty();
} }
void CppCompletionAssistProcessor::completeInclude(const QString &realPath, void InternalCppCompletionAssistProcessor::completeInclude(const QString &realPath,
const QStringList &suffixes) const QStringList &suffixes)
{ {
QDirIterator i(realPath, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot); QDirIterator i(realPath, QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
while (i.hasNext()) { while (i.hasNext()) {
@@ -1174,7 +1174,7 @@ void CppCompletionAssistProcessor::completeInclude(const QString &realPath,
} }
} }
void CppCompletionAssistProcessor::completePreprocessor() void InternalCppCompletionAssistProcessor::completePreprocessor()
{ {
foreach (const QString &preprocessorCompletion, preprocessorCompletions) foreach (const QString &preprocessorCompletion, preprocessorCompletions)
addCompletionItem(preprocessorCompletion); addCompletionItem(preprocessorCompletion);
@@ -1183,7 +1183,7 @@ void CppCompletionAssistProcessor::completePreprocessor()
addCompletionItem(QLatin1String("import")); addCompletionItem(QLatin1String("import"));
} }
bool CppCompletionAssistProcessor::objcKeywordsWanted() const bool InternalCppCompletionAssistProcessor::objcKeywordsWanted() const
{ {
if (!m_languageFeatures.objCEnabled) if (!m_languageFeatures.objCEnabled)
return false; return false;
@@ -1195,10 +1195,10 @@ bool CppCompletionAssistProcessor::objcKeywordsWanted() const
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE); || mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE);
} }
int CppCompletionAssistProcessor::startCompletionInternal(const QString &fileName, int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString &fileName,
unsigned line, unsigned column, unsigned line, unsigned column,
const QString &expr, const QString &expr,
int endOfExpression) int endOfExpression)
{ {
QString expression = expr.trimmed(); QString expression = expr.trimmed();
@@ -1311,7 +1311,7 @@ int CppCompletionAssistProcessor::startCompletionInternal(const QString &fileNam
return -1; return -1;
} }
void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentScope) void InternalCppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentScope)
{ {
const LookupContext &context = m_model->m_typeOfExpression->context(); const LookupContext &context = m_model->m_typeOfExpression->context();
@@ -1388,7 +1388,8 @@ void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentSco
addSnippets(); addSnippets();
} }
bool CppCompletionAssistProcessor::completeMember(const QList<CPlusPlus::LookupItem> &baseResults) bool InternalCppCompletionAssistProcessor::completeMember(
const QList<CPlusPlus::LookupItem> &baseResults)
{ {
const LookupContext &context = m_model->m_typeOfExpression->context(); const LookupContext &context = m_model->m_typeOfExpression->context();
@@ -1414,7 +1415,8 @@ bool CppCompletionAssistProcessor::completeMember(const QList<CPlusPlus::LookupI
return false; return false;
} }
bool CppCompletionAssistProcessor::completeScope(const QList<CPlusPlus::LookupItem> &results) bool InternalCppCompletionAssistProcessor::completeScope(
const QList<CPlusPlus::LookupItem> &results)
{ {
const LookupContext &context = m_model->m_typeOfExpression->context(); const LookupContext &context = m_model->m_typeOfExpression->context();
if (results.isEmpty()) if (results.isEmpty())
@@ -1481,7 +1483,7 @@ bool CppCompletionAssistProcessor::completeScope(const QList<CPlusPlus::LookupIt
return !m_completions.isEmpty(); return !m_completions.isEmpty();
} }
void CppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace *b) void InternalCppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace *b)
{ {
QSet<ClassOrNamespace *> bindingsVisited; QSet<ClassOrNamespace *> bindingsVisited;
QList<ClassOrNamespace *> bindingsToVisit; QList<ClassOrNamespace *> bindingsToVisit;
@@ -1521,7 +1523,8 @@ void CppCompletionAssistProcessor::completeNamespace(CPlusPlus::ClassOrNamespace
} }
} }
void CppCompletionAssistProcessor::completeClass(CPlusPlus::ClassOrNamespace *b, bool staticLookup) void InternalCppCompletionAssistProcessor::completeClass(CPlusPlus::ClassOrNamespace *b,
bool staticLookup)
{ {
QSet<ClassOrNamespace *> bindingsVisited; QSet<ClassOrNamespace *> bindingsVisited;
QList<ClassOrNamespace *> bindingsToVisit; QList<ClassOrNamespace *> bindingsToVisit;
@@ -1563,7 +1566,8 @@ void CppCompletionAssistProcessor::completeClass(CPlusPlus::ClassOrNamespace *b,
} }
} }
void CppCompletionAssistProcessor::addClassMembersToCompletion(Scope *scope, bool staticLookup) void InternalCppCompletionAssistProcessor::addClassMembersToCompletion(Scope *scope,
bool staticLookup)
{ {
if (!scope) if (!scope)
return; return;
@@ -1598,7 +1602,9 @@ void CppCompletionAssistProcessor::addClassMembersToCompletion(Scope *scope, boo
addClassMembersToCompletion(*cit, staticLookup); addClassMembersToCompletion(*cit, staticLookup);
} }
bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::LookupItem> &results, bool wantSignals) bool InternalCppCompletionAssistProcessor::completeQtMethod(
const QList<CPlusPlus::LookupItem> &results,
bool wantSignals)
{ {
if (results.isEmpty()) if (results.isEmpty())
return false; return false;
@@ -1700,12 +1706,12 @@ bool CppCompletionAssistProcessor::completeQtMethod(const QList<CPlusPlus::Looku
return !m_completions.isEmpty(); return !m_completions.isEmpty();
} }
void CppCompletionAssistProcessor::addSnippets() void InternalCppCompletionAssistProcessor::addSnippets()
{ {
m_completions.append(m_snippetCollector.collect()); m_completions.append(m_snippetCollector.collect());
} }
void CppCompletionAssistProcessor::addKeywords() void InternalCppCompletionAssistProcessor::addKeywords()
{ {
int keywordLimit = T_FIRST_OBJC_AT_KEYWORD; int keywordLimit = T_FIRST_OBJC_AT_KEYWORD;
if (objcKeywordsWanted()) if (objcKeywordsWanted())
@@ -1720,7 +1726,8 @@ void CppCompletionAssistProcessor::addKeywords()
addCompletionItem(QLatin1String(Token::name(i)), m_icons.keywordIcon(), KeywordsOrder); addCompletionItem(QLatin1String(Token::name(i)), m_icons.keywordIcon(), KeywordsOrder);
} }
void CppCompletionAssistProcessor::addMacros(const QString &fileName, const CPlusPlus::Snapshot &snapshot) void InternalCppCompletionAssistProcessor::addMacros(const QString &fileName,
const CPlusPlus::Snapshot &snapshot)
{ {
QSet<QString> processed; QSet<QString> processed;
QSet<QString> definedMacros; QSet<QString> definedMacros;
@@ -1731,7 +1738,7 @@ void CppCompletionAssistProcessor::addMacros(const QString &fileName, const CPlu
addCompletionItem(macroName, m_icons.macroIcon(), MacrosOrder); addCompletionItem(macroName, m_icons.macroIcon(), MacrosOrder);
} }
void CppCompletionAssistProcessor::addMacros_helper(const CPlusPlus::Snapshot &snapshot, void InternalCppCompletionAssistProcessor::addMacros_helper(const CPlusPlus::Snapshot &snapshot,
const QString &fileName, const QString &fileName,
QSet<QString> *processed, QSet<QString> *processed,
QSet<QString> *definedMacros) QSet<QString> *definedMacros)
@@ -1755,9 +1762,9 @@ void CppCompletionAssistProcessor::addMacros_helper(const CPlusPlus::Snapshot &s
} }
} }
bool CppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPlusPlus::LookupItem> &results, bool InternalCppCompletionAssistProcessor::completeConstructorOrFunction(const QList<CPlusPlus::LookupItem> &results,
int endOfExpression, int endOfExpression,
bool toolTipOnly) bool toolTipOnly)
{ {
const LookupContext &context = m_model->m_typeOfExpression->context(); const LookupContext &context = m_model->m_typeOfExpression->context();
QList<Function *> functions; QList<Function *> functions;

View File

@@ -96,11 +96,11 @@ public:
TextEditor::AssistReason reason) const Q_DECL_OVERRIDE; TextEditor::AssistReason reason) const Q_DECL_OVERRIDE;
}; };
class CppCompletionAssistProcessor : public TextEditor::IAssistProcessor class InternalCppCompletionAssistProcessor : public TextEditor::IAssistProcessor
{ {
public: public:
CppCompletionAssistProcessor(); InternalCppCompletionAssistProcessor();
~CppCompletionAssistProcessor(); ~InternalCppCompletionAssistProcessor();
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) Q_DECL_OVERRIDE; TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) Q_DECL_OVERRIDE;