Commit 415d3c47 authored by Nikolai Kosjar's avatar Nikolai Kosjar

Clang: Fix cursor position after completion of overloads

struct Foo {
    void begin();
    void begin() const;
};

void c(Foo &foo)
{
    foo.beg // complete to foo.begin()| instead of foo.begin(|)
}

Task-number: QTCREATORBUG-17443
Change-Id: I60ca16bbfeeb75c5c37a0d5bc6f46e9e9913b86e
Reviewed-by: Ivan Donchevskii's avatarIvan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Marco Bubke's avatarMarco Bubke <marco.bubke@qt.io>
parent e5631e2e
......@@ -154,7 +154,7 @@ void ClangAssistProposalItem::apply(TextEditor::TextDocumentManipulatorInterface
}
// If the function takes no arguments, automatically place the closing parenthesis
if (!isOverloaded() && !ccr.hasParameters() && skipClosingParenthesis) {
if (!hasOverloadsWithParameters() && !ccr.hasParameters() && skipClosingParenthesis) {
extraCharacters += QLatin1Char(')');
if (endWithSemicolon) {
extraCharacters += semicolon;
......@@ -333,19 +333,19 @@ quint64 ClangAssistProposalItem::hash() const
return 0;
}
void ClangAssistProposalItem::keepCompletionOperator(unsigned compOp)
bool ClangAssistProposalItem::hasOverloadsWithParameters() const
{
m_completionOperator = compOp;
return m_hasOverloadsWithParameters;
}
bool ClangAssistProposalItem::isOverloaded() const
void ClangAssistProposalItem::setHasOverloadsWithParameters(bool hasOverloadsWithParameters)
{
return !m_overloads.isEmpty();
m_hasOverloadsWithParameters = hasOverloadsWithParameters;
}
void ClangAssistProposalItem::addOverload(const CodeCompletion &ccr)
void ClangAssistProposalItem::keepCompletionOperator(unsigned compOp)
{
m_overloads.append(ccr);
m_completionOperator = compOp;
}
void ClangAssistProposalItem::setCodeCompletion(const CodeCompletion &codeCompletion)
......
......@@ -53,8 +53,8 @@ public:
void keepCompletionOperator(unsigned compOp);
bool isOverloaded() const;
void addOverload(const ClangBackEnd::CodeCompletion &ccr);
bool hasOverloadsWithParameters() const;
void setHasOverloadsWithParameters(bool hasOverloadsWithParameters);
void setCodeCompletion(const ClangBackEnd::CodeCompletion &codeCompletion);
const ClangBackEnd::CodeCompletion &codeCompletion() const;
......@@ -62,6 +62,7 @@ public:
private:
ClangBackEnd::CodeCompletion m_codeCompletion;
QList<ClangBackEnd::CodeCompletion> m_overloads;
bool m_hasOverloadsWithParameters = false;
QString m_text;
unsigned m_completionOperator;
mutable QChar m_typedCharacter;
......
......@@ -89,7 +89,8 @@ QList<AssistProposalItemInterface *> toAssistProposalItems(const CodeCompletions
ClangAssistProposalItem *item = items.value(name, 0);
if (item) {
item->addOverload(codeCompletion);
if (codeCompletion.hasParameters())
item->setHasOverloadsWithParameters(true);
} else {
item = new ClangAssistProposalItem;
items.insert(name, item);
......
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