| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library services.src.correction.util; | 5 library services.src.correction.util; |
| 6 | 6 |
| 7 import 'dart:math'; | 7 import 'dart:math'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart' | 9 import 'package:analysis_server/plugin/protocol/protocol.dart' |
| 10 show SourceChange, SourceEdit; | 10 show SourceChange, SourceEdit; |
| 11 import 'package:analysis_server/src/protocol_server.dart' | 11 import 'package:analysis_server/src/protocol_server.dart' |
| 12 show doSourceChange_addElementEdit; | 12 show doSourceChange_addElementEdit; |
| 13 import 'package:analysis_server/src/services/correction/source_range.dart'; | 13 import 'package:analysis_server/src/services/correction/source_range.dart'; |
| 14 import 'package:analysis_server/src/services/correction/strings.dart'; | 14 import 'package:analysis_server/src/services/correction/strings.dart'; |
| 15 import 'package:analysis_server/src/services/search/element_visitors.dart'; | 15 import 'package:analysis_server/src/services/search/element_visitors.dart'; |
| 16 import 'package:analyzer/dart/element/element.dart'; |
| 17 import 'package:analyzer/dart/element/type.dart'; |
| 16 import 'package:analyzer/src/generated/ast.dart'; | 18 import 'package:analyzer/src/generated/ast.dart'; |
| 17 import 'package:analyzer/src/generated/element.dart'; | |
| 18 import 'package:analyzer/src/generated/engine.dart'; | 19 import 'package:analyzer/src/generated/engine.dart'; |
| 19 import 'package:analyzer/src/generated/resolver.dart'; | 20 import 'package:analyzer/src/generated/resolver.dart'; |
| 20 import 'package:analyzer/src/generated/scanner.dart'; | 21 import 'package:analyzer/src/generated/scanner.dart'; |
| 21 import 'package:analyzer/src/generated/source.dart'; | 22 import 'package:analyzer/src/generated/source.dart'; |
| 22 import 'package:path/path.dart'; | 23 import 'package:path/path.dart'; |
| 23 | 24 |
| 24 /** | 25 /** |
| 25 * Adds edits to the given [change] that ensure that all the [libraries] are | 26 * Adds edits to the given [change] that ensure that all the [libraries] are |
| 26 * imported into the given [targetLibrary]. | 27 * imported into the given [targetLibrary]. |
| 27 */ | 28 */ |
| (...skipping 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 if (operator == TokenType.BAR_BAR) { | 1293 if (operator == TokenType.BAR_BAR) { |
| 1293 return _InvertedCondition._binary( | 1294 return _InvertedCondition._binary( |
| 1294 TokenType.AMPERSAND_AMPERSAND.precedence, ls, " && ", rs); | 1295 TokenType.AMPERSAND_AMPERSAND.precedence, ls, " && ", rs); |
| 1295 } | 1296 } |
| 1296 } | 1297 } |
| 1297 if (expression is IsExpression) { | 1298 if (expression is IsExpression) { |
| 1298 IsExpression isExpression = expression; | 1299 IsExpression isExpression = expression; |
| 1299 String expressionSource = getNodeText(isExpression.expression); | 1300 String expressionSource = getNodeText(isExpression.expression); |
| 1300 String typeSource = getNodeText(isExpression.type); | 1301 String typeSource = getNodeText(isExpression.type); |
| 1301 if (isExpression.notOperator == null) { | 1302 if (isExpression.notOperator == null) { |
| 1302 return _InvertedCondition | 1303 return _InvertedCondition._simple("$expressionSource is! $typeSource"); |
| 1303 ._simple("$expressionSource is! $typeSource"); | |
| 1304 } else { | 1304 } else { |
| 1305 return _InvertedCondition | 1305 return _InvertedCondition._simple("$expressionSource is $typeSource"); |
| 1306 ._simple("$expressionSource is $typeSource"); | |
| 1307 } | 1306 } |
| 1308 } | 1307 } |
| 1309 if (expression is PrefixExpression) { | 1308 if (expression is PrefixExpression) { |
| 1310 PrefixExpression prefixExpression = expression; | 1309 PrefixExpression prefixExpression = expression; |
| 1311 TokenType operator = prefixExpression.operator.type; | 1310 TokenType operator = prefixExpression.operator.type; |
| 1312 if (operator == TokenType.BANG) { | 1311 if (operator == TokenType.BANG) { |
| 1313 Expression operand = prefixExpression.operand; | 1312 Expression operand = prefixExpression.operand; |
| 1314 while (operand is ParenthesizedExpression) { | 1313 while (operand is ParenthesizedExpression) { |
| 1315 ParenthesizedExpression pe = operand as ParenthesizedExpression; | 1314 ParenthesizedExpression pe = operand as ParenthesizedExpression; |
| 1316 operand = pe.expression; | 1315 operand = pe.expression; |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1471 _InvertedCondition expr, int newOperatorPrecedence) { | 1470 _InvertedCondition expr, int newOperatorPrecedence) { |
| 1472 if (expr._precedence < newOperatorPrecedence) { | 1471 if (expr._precedence < newOperatorPrecedence) { |
| 1473 return "(${expr._source})"; | 1472 return "(${expr._source})"; |
| 1474 } | 1473 } |
| 1475 return expr._source; | 1474 return expr._source; |
| 1476 } | 1475 } |
| 1477 | 1476 |
| 1478 static _InvertedCondition _simple(String source) => | 1477 static _InvertedCondition _simple(String source) => |
| 1479 new _InvertedCondition(2147483647, source); | 1478 new _InvertedCondition(2147483647, source); |
| 1480 } | 1479 } |
| OLD | NEW |