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 import 'dart:math'; | 5 import 'dart:math'; |
6 | 6 |
7 import 'package:analysis_server/src/protocol_server.dart' | 7 import 'package:analysis_server/src/protocol_server.dart' |
8 show doSourceChange_addElementEdit; | 8 show doSourceChange_addElementEdit; |
9 import 'package:analysis_server/src/services/correction/strings.dart'; | 9 import 'package:analysis_server/src/services/correction/strings.dart'; |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 211 } |
212 if (typeName == "String") { | 212 if (typeName == "String") { |
213 return "''"; | 213 return "''"; |
214 } | 214 } |
215 } | 215 } |
216 // no better guess | 216 // no better guess |
217 return "null"; | 217 return "null"; |
218 } | 218 } |
219 | 219 |
220 /** | 220 /** |
| 221 * Return all [LocalElement]s defined in the given [node]. |
| 222 */ |
| 223 List<LocalElement> getDefinedLocalElements(AstNode node) { |
| 224 var collector = new _LocalElementsCollector(); |
| 225 node.accept(collector); |
| 226 return collector.elements; |
| 227 } |
| 228 |
| 229 /** |
221 * Return the name of the [Element] kind. | 230 * Return the name of the [Element] kind. |
222 */ | 231 */ |
223 String getElementKindName(Element element) { | 232 String getElementKindName(Element element) { |
224 return element.kind.displayName; | 233 return element.kind.displayName; |
225 } | 234 } |
226 | 235 |
227 /** | 236 /** |
228 * Returns the name to display in the UI for the given [Element]. | 237 * Returns the name to display in the UI for the given [Element]. |
229 */ | 238 */ |
230 String getElementQualifiedName(Element element) { | 239 String getElementQualifiedName(Element element) { |
(...skipping 1299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1530 _InvertedCondition expr, int newOperatorPrecedence) { | 1539 _InvertedCondition expr, int newOperatorPrecedence) { |
1531 if (expr._precedence < newOperatorPrecedence) { | 1540 if (expr._precedence < newOperatorPrecedence) { |
1532 return "(${expr._source})"; | 1541 return "(${expr._source})"; |
1533 } | 1542 } |
1534 return expr._source; | 1543 return expr._source; |
1535 } | 1544 } |
1536 | 1545 |
1537 static _InvertedCondition _simple(String source) => | 1546 static _InvertedCondition _simple(String source) => |
1538 new _InvertedCondition(2147483647, source); | 1547 new _InvertedCondition(2147483647, source); |
1539 } | 1548 } |
| 1549 |
| 1550 /** |
| 1551 * Visitor that collects defined [LocalElement]s. |
| 1552 */ |
| 1553 class _LocalElementsCollector extends RecursiveAstVisitor { |
| 1554 final elements = <LocalElement>[]; |
| 1555 |
| 1556 @override |
| 1557 visitSimpleIdentifier(SimpleIdentifier node) { |
| 1558 if (node.inDeclarationContext()) { |
| 1559 Element element = node.staticElement; |
| 1560 if (element is LocalElement) { |
| 1561 elements.add(element); |
| 1562 } |
| 1563 } |
| 1564 } |
| 1565 } |
OLD | NEW |