diff options
author | Eike Ziller <eike.ziller@digia.com> | 2013-06-27 14:24:57 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@digia.com> | 2013-06-27 14:24:57 +0200 |
commit | c9128b7fdd59f8482fcd5e8bc5e0d481ad5e86d1 (patch) | |
tree | 421eb840b83dc79a2fd958eb4af25c88d0dce97f /src/plugins/cpptools/cpppointerdeclarationformatter.cpp | |
parent | 9055eea11f86fce9157970088af0832cff17e1df (diff) | |
parent | 6c8f87556a2c7acdddca750e078b568ba082acf3 (diff) | |
download | qt-creator-c9128b7fdd59f8482fcd5e8bc5e0d481ad5e86d1.tar.gz |
Merge remote-tracking branch 'origin/2.8'
Conflicts:
qtcreator.pri
qtcreator.qbs
Change-Id: I1aa7506519e0f461f33921ca20ce1b51adb5783f
Diffstat (limited to 'src/plugins/cpptools/cpppointerdeclarationformatter.cpp')
-rw-r--r-- | src/plugins/cpptools/cpppointerdeclarationformatter.cpp | 36 |
1 files changed, 7 insertions, 29 deletions
diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter.cpp index bb4291b5e7..edcb105028 100644 --- a/src/plugins/cpptools/cpppointerdeclarationformatter.cpp +++ b/src/plugins/cpptools/cpppointerdeclarationformatter.cpp @@ -115,7 +115,7 @@ static unsigned firstTypeSpecifierWithoutFollowingAttribute( PointerDeclarationFormatter::PointerDeclarationFormatter( const CppRefactoringFilePtr refactoringFile, - const Overview &overview, + Overview &overview, CursorHandling cursorHandling) : ASTVisitor(refactoringFile->cppDocument()->translationUnit()) , m_cppRefactoringFile(refactoringFile) @@ -413,21 +413,14 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator, QString rewrittenDeclaration; const Name *name = symbol->name(); if (name) { - if (name->isOperatorNameId()) { - // Take the operator name from the file instead from the AST, so the white - // spaces within the operator names can be respected, e.g. in "operator =". - const QByteArray operatorText - = m_cppRefactoringFile->textOf(declarator->core_declarator).toLatin1(); - Identifier operatorName(operatorText.constData(), operatorText.size()); - rewrittenDeclaration = rewriteDeclaration(type, &operatorName); - } else { - rewrittenDeclaration = rewriteDeclaration(type, name); + if (name->isOperatorNameId() + || (name->isQualifiedNameId() + && name->asQualifiedNameId()->name()->isOperatorNameId())) { + const QString operatorText = m_cppRefactoringFile->textOf(declarator->core_declarator); + m_overview.includeWhiteSpaceInOperatorName = operatorText.contains(QLatin1Char(' ')); } - } else { - // The declaration will be correctly rewritten for name == 0 (e.g. "int *"). - rewrittenDeclaration = rewriteDeclaration(type, name); } - + rewrittenDeclaration = m_overview.prettyType(type, name); rewrittenDeclaration.remove(0, charactersToRemove); CHECK_R(originalDeclaration != rewrittenDeclaration, "Rewritten is same as original"); @@ -460,21 +453,6 @@ void PointerDeclarationFormatter::checkAndRewrite(DeclaratorAST *declarator, qDebug() << "Replacement operation failed"; } -/*! Rewrite/format the given type and name. */ -QString PointerDeclarationFormatter::rewriteDeclaration(FullySpecifiedType type, const Name *name) - const -{ - CHECK_RV(type.isValid(), "Invalid type", QString()); - - const char *identifier = 0; - if (const Name *declarationName = name) { - if (const Identifier *id = declarationName->identifier()) - identifier = id->chars(); - } - - return m_overview.prettyType(type, QLatin1String(identifier)); -} - void PointerDeclarationFormatter::printCandidate(AST *ast) { #if DEBUG_OUTPUT |