Skip to content
Snippets Groups Projects
Commit f9effd16 authored by Christian Kamm's avatar Christian Kamm
Browse files

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: default avatarLeandro T. C. Melo <leandro.melo@nokia.com>
parent a1fa1692
No related branches found
No related tags found
No related merge requests found
...@@ -437,10 +437,17 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ ...@@ -437,10 +437,17 @@ Utils::ChangeSet FunctionDeclDefLink::changes(const Snapshot &snapshot, int targ
// parse the current source declaration // parse the current source declaration
TypeOfExpression typeOfExpression; // ### just need to preprocess... TypeOfExpression typeOfExpression; // ### just need to preprocess...
typeOfExpression.init(sourceDocument, snapshot); 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>")); Document::Ptr newDeclDoc = Document::create(QLatin1String("<decl>"));
newDeclDoc->setSource(newDecl.toUtf8()); newDeclDoc->setSource(newDeclTextPreprocessed.toUtf8());
newDeclDoc->parse(Document::ParseDeclaration); newDeclDoc->parse(Document::ParseDeclaration);
newDeclDoc->check(); newDeclDoc->check();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment