Commit 793ca970 authored by Alexey Semenko's avatar Alexey Semenko Committed by mae

Add "insert space after function name" option for GNU indenting

Reviewed-by: mae
Merge-request: 133
parent 538921e8
......@@ -96,10 +96,12 @@ QWidget *CompletionSettingsPage::createPage(QWidget *parent)
m_page->caseSensitivity->setCurrentIndex(caseSensitivityIndex);
m_page->autoInsertBrackets->setChecked(m_completion->autoInsertBrackets());
m_page->partiallyComplete->setChecked(m_completion->isPartialCompletionEnabled());
m_page->spaceAfterFunctionName->setChecked(m_completion->isSpaceAfterFunctionName());
if (m_searchKeywords.isEmpty()) {
QTextStream(&m_searchKeywords) << m_page->caseSensitivityLabel->text()
<< ' ' << m_page->autoInsertBrackets->text()
<< ' ' << m_page->partiallyComplete->text();
<< ' ' << m_page->partiallyComplete->text()
<< ' ' << m_page->spaceAfterFunctionName->text();
m_searchKeywords.remove(QLatin1Char('&'));
}
return w;
......@@ -110,6 +112,7 @@ void CompletionSettingsPage::apply()
m_completion->setCaseSensitivity(caseSensitivity());
m_completion->setAutoInsertBrackets(m_page->autoInsertBrackets->isChecked());
m_completion->setPartialCompletionEnabled(m_page->partiallyComplete->isChecked());
m_completion->setSpaceAfterFunctionName(m_page->spaceAfterFunctionName->isChecked());
}
bool CompletionSettingsPage::matches(const QString &s) const
......
......@@ -111,6 +111,16 @@
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="spaceAfterFunctionName">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>Insert &amp;space after function name</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
......
......@@ -479,6 +479,7 @@ CppCodeCompletion::CppCodeCompletion(CppModelManager *manager)
m_caseSensitivity(FirstLetterCaseSensitive),
m_autoInsertBrackets(true),
m_partialCompletionEnabled(true),
m_spaceAfterFunctionName(false),
m_forcedCompletion(false),
m_completionOperator(T_EOF_SYMBOL),
m_objcEnabled(true)
......@@ -520,6 +521,16 @@ void CppCodeCompletion::setPartialCompletionEnabled(bool partialCompletionEnable
m_partialCompletionEnabled = partialCompletionEnabled;
}
bool CppCodeCompletion::isSpaceAfterFunctionName() const
{
return m_spaceAfterFunctionName;
}
void CppCodeCompletion::setSpaceAfterFunctionName(bool spaceAfterFunctionName)
{
m_spaceAfterFunctionName = spaceAfterFunctionName;
}
/*
Searches backwards for an access operator.
*/
......@@ -1580,6 +1591,8 @@ void CppCodeCompletion::complete(const TextEditor::CompletionItem &item)
extraChars += QLatin1Char('<');
}
} else if (! function->isAmbiguous()) {
if (m_spaceAfterFunctionName)
extraChars += QLatin1Char(' ');
extraChars += QLatin1Char('(');
// If the function doesn't return anything, automatically place the semicolon,
......
......@@ -88,6 +88,9 @@ public:
bool isPartialCompletionEnabled() const;
void setPartialCompletionEnabled(bool partialCompletionEnabled);
bool isSpaceAfterFunctionName() const;
void setSpaceAfterFunctionName(bool spaceAfterFunctionName);
private:
void addKeywords();
void addMacros(const QString &fileName, const CPlusPlus::Snapshot &snapshot);
......@@ -152,6 +155,7 @@ private:
CaseSensitivity m_caseSensitivity;
bool m_autoInsertBrackets;
bool m_partialCompletionEnabled;
bool m_spaceAfterFunctionName;
bool m_forcedCompletion;
unsigned m_completionOperator;
bool m_objcEnabled;
......
......@@ -147,6 +147,7 @@ bool CppToolsPlugin::initialize(const QStringList &arguments, QString *error)
m_completion->setCaseSensitivity((CppCodeCompletion::CaseSensitivity) caseSensitivity);
m_completion->setAutoInsertBrackets(settings->value(QLatin1String("AutoInsertBraces"), true).toBool());
m_completion->setPartialCompletionEnabled(settings->value(QLatin1String("PartiallyComplete"), true).toBool());
m_completion->setSpaceAfterFunctionName(settings->value(QLatin1String("SpaceAfterFunctionName"), false).toBool());
settings->endGroup();
settings->endGroup();
......@@ -176,6 +177,7 @@ void CppToolsPlugin::shutdown()
settings->setValue(QLatin1String("CaseSensitivity"), (int) m_completion->caseSensitivity());
settings->setValue(QLatin1String("AutoInsertBraces"), m_completion->autoInsertBrackets());
settings->setValue(QLatin1String("PartiallyComplete"), m_completion->isPartialCompletionEnabled());
settings->setValue(QLatin1String("SpaceAfterFunctionName"), m_completion->isSpaceAfterFunctionName());
settings->endGroup();
settings->endGroup();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment