| 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 computer.hover; | 5 library computer.hover; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol.dart' show HoverInformation; | 7 import 'package:analysis_server/src/protocol.dart' show HoverInformation; |
| 8 import 'package:analyzer/src/generated/ast.dart'; | 8 import 'package:analyzer/src/generated/ast.dart'; |
| 9 import 'package:analyzer/src/generated/element.dart'; | 9 import 'package:analyzer/src/generated/element.dart'; |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 class DartUnitHoverComputer { | 58 class DartUnitHoverComputer { |
| 59 final CompilationUnit _unit; | 59 final CompilationUnit _unit; |
| 60 final int _offset; | 60 final int _offset; |
| 61 | 61 |
| 62 DartUnitHoverComputer(this._unit, this._offset); | 62 DartUnitHoverComputer(this._unit, this._offset); |
| 63 | 63 |
| 64 /** | 64 /** |
| 65 * Returns the computed hover, maybe `null`. | 65 * Returns the computed hover, maybe `null`. |
| 66 */ | 66 */ |
| 67 HoverInformation compute() { | 67 HoverInformation compute() { |
| 68 AstNode node = new NodeLocator.con1(_offset).searchWithin(_unit); | 68 AstNode node = new NodeLocator(_offset).searchWithin(_unit); |
| 69 if (node == null) { | 69 if (node == null) { |
| 70 return null; | 70 return null; |
| 71 } | 71 } |
| 72 if (node.parent is TypeName && | 72 if (node.parent is TypeName && |
| 73 node.parent.parent is ConstructorName && | 73 node.parent.parent is ConstructorName && |
| 74 node.parent.parent.parent is InstanceCreationExpression) { | 74 node.parent.parent.parent is InstanceCreationExpression) { |
| 75 node = node.parent.parent.parent; | 75 node = node.parent.parent.parent; |
| 76 } | 76 } |
| 77 if (node.parent is ConstructorName && | 77 if (node.parent is ConstructorName && |
| 78 node.parent.parent is InstanceCreationExpression) { | 78 node.parent.parent is InstanceCreationExpression) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 hover.propagatedType = _safeToString(expression.propagatedType); | 122 hover.propagatedType = _safeToString(expression.propagatedType); |
| 123 // done | 123 // done |
| 124 return hover; | 124 return hover; |
| 125 } | 125 } |
| 126 // not an expression | 126 // not an expression |
| 127 return null; | 127 return null; |
| 128 } | 128 } |
| 129 | 129 |
| 130 static _safeToString(obj) => obj != null ? obj.toString() : null; | 130 static _safeToString(obj) => obj != null ? obj.toString() : null; |
| 131 } | 131 } |
| OLD | NEW |