C++ function signature: Fix problem with multiline declarations.

QTextCursor::selectedText() has null chars where the tokenizer expects
newlines.

Change-Id: I15ae87ef8525c89812a61b80abda91d36bf56576
Reviewed-on: http://codereview.qt-project.org/4450
Reviewed-by: Leandro T. C. Melo <leandro.melo@nokia.com>
This commit is contained in:
Christian Kamm
2011-09-08 14:47:19 +02:00
parent a1fa169219
commit f9effd16b3

View File

@@ -437,10 +437,17 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
// parse the current source declaration
TypeOfExpression typeOfExpression; // ### just need to preprocess...
typeOfExpression.init(sourceDocument, snapshot);
const QString newDecl = typeOfExpression.preprocess(
linkSelection.selectedText()) + QLatin1String("{}");
QString newDeclText = linkSelection.selectedText();
for (int i = 0; i < newDeclText.size(); ++i) {
if (newDeclText.at(i).toAscii() == 0)
newDeclText[i] = QLatin1Char('\n');
}
newDeclText.append(QLatin1String("{}"));
const QString newDeclTextPreprocessed = typeOfExpression.preprocess(newDeclText);
Document::Ptr newDeclDoc = Document::create(QLatin1String("<decl>"));
newDeclDoc->setSource(newDecl.toUtf8());
newDeclDoc->setSource(newDeclTextPreprocessed.toUtf8());
newDeclDoc->parse(Document::ParseDeclaration);
newDeclDoc->check();