Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(316)

Unified Diff: pkg/analysis_server/lib/src/services/correction/assist_internal.dart

Issue 805053003: Disable 'Split && condition' if there is an 'else' statement. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/assist_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/correction/assist_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
index 76314e9159e036c22ae65386b0befe3345d84580..2fcc8c3d0150088383cac95dc870b6375185cd13 100644
--- a/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/assist_internal.dart
@@ -1259,6 +1259,11 @@ class AssistProcessor {
return;
}
IfStatement ifStatement = statement as IfStatement;
+ // no support "else"
+ if (ifStatement.elseStatement != null) {
+ _coverageMarker();
+ return;
+ }
// check that binary expression is part of first level && condition of "if"
BinaryExpression condition = binaryExpression;
while (condition.parent is BinaryExpression &&
@@ -1284,7 +1289,6 @@ class AssistProcessor {
_addRemoveEdit(rangeEndEnd(binaryExpression.leftOperand, condition));
// update "then" statement
Statement thenStatement = ifStatement.thenStatement;
- Statement elseStatement = ifStatement.elseStatement;
if (thenStatement is Block) {
Block thenBlock = thenStatement;
SourceRange thenBlockRange = rangeNode(thenBlock);
@@ -1299,41 +1303,14 @@ class AssistProcessor {
{
int thenBlockEnd = thenBlockRange.end;
String source = "${indent}}";
- // may be move "else" statements
- if (elseStatement != null) {
- List<Statement> elseStatements = getStatements(elseStatement);
- SourceRange elseLinesRange =
- utils.getLinesRangeStatements(elseStatements);
- String elseIndentOld = "${prefix}${indent}";
- String elseIndentNew = "${elseIndentOld}${indent}";
- String newElseSource =
- utils.replaceSourceRangeIndent(elseLinesRange, elseIndentOld, elseIndentNew);
- // append "else" block
- source += " else {${eol}";
- source += newElseSource;
- source += "${prefix}${indent}}";
- // remove old "else" range
- _addRemoveEdit(rangeStartEnd(thenBlockEnd, elseStatement));
- }
// insert before outer "then" block "}"
source += "${eol}${prefix}";
_addInsertEdit(thenBlockEnd - 1, source);
}
} else {
// insert inner "if" with right part of "condition"
- {
- String source = "${eol}${prefix}${indent}if (${rightConditionSource})";
- _addInsertEdit(ifStatement.rightParenthesis.offset + 1, source);
- }
- // indent "else" statements to correspond inner "if"
- if (elseStatement != null) {
- SourceRange elseRange =
- rangeStartEnd(ifStatement.elseKeyword.offset, elseStatement);
- SourceRange elseLinesRange = utils.getLinesRange(elseRange);
- String elseIndentOld = prefix;
- String elseIndentNew = "${elseIndentOld}${indent}";
- _addIndentEdit(elseLinesRange, elseIndentOld, elseIndentNew);
- }
+ String source = "${eol}${prefix}${indent}if (${rightConditionSource})";
+ _addInsertEdit(ifStatement.rightParenthesis.offset + 1, source);
}
// indent "then" statements to correspond inner "if"
{
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/assist_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698