Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Marco Bubke
flatpak-qt-creator
Commits
b437b4be
Commit
b437b4be
authored
Nov 23, 2009
by
Christian Kamm
Browse files
QuickFix: split && correctly when compound statements are involved.
Reviewed-by:
Roberto Raggi
<
roberto.raggi@nokia.com
>
parent
b5bd72fb
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/plugins/cppeditor/cppquickfix.cpp
View file @
b437b4be
...
...
@@ -471,7 +471,6 @@ public:
void
splitAndCondition
()
{
StatementAST
*
ifTrueStatement
=
pattern
->
statement
;
CompoundStatementAST
*
compoundStatement
=
ifTrueStatement
->
asCompoundStatement
();
// take the right-expression from the condition.
QTextCursor
rightCursor
=
textCursor
();
...
...
@@ -480,27 +479,14 @@ public:
const
QString
rightCondition
=
rightCursor
.
selectedText
();
replace
(
endOf
(
condition
->
left_expression
),
startOf
(
pattern
->
rparen_token
),
QString
());
int
offset
=
0
;
if
(
compoundStatement
)
offset
=
endOf
(
compoundStatement
->
lbrace_token
);
else
offset
=
endOf
(
pattern
->
rparen_token
);
// create the nested if statement
QString
nestedIfStatement
;
if
(
!
compoundStatement
)
nestedIfStatement
+=
QLatin1String
(
" {"
);
// open a compound statement
nestedIfStatement
+=
QLatin1String
(
"
\n
if ("
);
nestedIfStatement
+=
QLatin1String
(
" {
\n
if ("
);
// open new compound statement for outer
nestedIfStatement
+=
rightCondition
;
nestedIfStatement
+=
QLatin1String
(
") {
\n
}"
);
insert
(
offset
,
nestedIfStatement
);
nestedIfStatement
+=
QLatin1String
(
")"
);
i
f
(
!
compound
Statement
)
insert
(
endOf
(
ifTrueStatement
),
"
\n
}"
);
// finish the compound statement
i
nsert
(
endOf
(
pattern
->
rparen_token
),
nestedIf
Statement
)
;
insert
(
endOf
(
ifTrueStatement
),
"
\n
}"
);
// finish the compound statement
applyChanges
(
pattern
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment