forked from qt-creator/qt-creator
Added #preprocessor directive completion.
This commit is contained in:
@@ -518,6 +518,10 @@ static int startOfOperator(TextEditor::ITextEditable *editor,
|
||||
completionKind = T_SLASH;
|
||||
--start;
|
||||
break;
|
||||
case '#':
|
||||
completionKind = T_POUND;
|
||||
--start;
|
||||
break;
|
||||
}
|
||||
|
||||
if (start == pos)
|
||||
@@ -673,6 +677,13 @@ int CppCodeCompletion::startCompletion(TextEditor::ITextEditable *editor)
|
||||
return m_startPosition;
|
||||
}
|
||||
|
||||
// Pre-processor completion
|
||||
if (m_completionOperator == T_POUND) {
|
||||
completePreprocessor();
|
||||
m_startPosition = startOfName;
|
||||
return m_startPosition;
|
||||
}
|
||||
|
||||
// Include completion
|
||||
if (m_completionOperator == T_STRING_LITERAL
|
||||
|| m_completionOperator == T_ANGLE_STRING_LITERAL
|
||||
@@ -1252,6 +1263,31 @@ bool CppCodeCompletion::completeInclude(const QTextCursor &cursor)
|
||||
return !m_completions.isEmpty();
|
||||
}
|
||||
|
||||
void CppCodeCompletion::completePreprocessor()
|
||||
{
|
||||
TextEditor::CompletionItem item(this);
|
||||
|
||||
item.text = QLatin1String("define"); m_completions.append(item);
|
||||
item.text = QLatin1String("error"); m_completions.append(item);
|
||||
item.text = QLatin1String("include"); m_completions.append(item);
|
||||
item.text = QLatin1String("line"); m_completions.append(item);
|
||||
item.text = QLatin1String("pragma"); m_completions.append(item);
|
||||
item.text = QLatin1String("undef"); m_completions.append(item);
|
||||
|
||||
item.text = QLatin1String("if"); m_completions.append(item);
|
||||
item.text = QLatin1String("ifdef"); m_completions.append(item);
|
||||
item.text = QLatin1String("ifndef"); m_completions.append(item);
|
||||
item.text = QLatin1String("elif"); m_completions.append(item);
|
||||
item.text = QLatin1String("else"); m_completions.append(item);
|
||||
item.text = QLatin1String("endif"); m_completions.append(item);
|
||||
|
||||
if (objcKeywordsWanted()) {
|
||||
TextEditor::CompletionItem item(this);
|
||||
item.text = QLatin1String("import");
|
||||
m_completions.append(item);
|
||||
}
|
||||
}
|
||||
|
||||
void CppCodeCompletion::completeNamespace(const QList<Symbol *> &candidates,
|
||||
const LookupContext &context)
|
||||
{
|
||||
|
||||
@@ -89,6 +89,7 @@ private:
|
||||
void addCompletionItem(CPlusPlus::Symbol *symbol);
|
||||
|
||||
bool completeInclude(const QTextCursor &cursor);
|
||||
void completePreprocessor();
|
||||
|
||||
int globalCompletion(CPlusPlus::Symbol *lastVisibleSymbol,
|
||||
CPlusPlus::Document::Ptr thisDocument,
|
||||
|
||||
Reference in New Issue
Block a user