| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analysis_server.src.provisional.completion.dart.completion_target; | 5 library analysis_server.src.provisional.completion.dart.completion_target; |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
| 8 import 'package:analyzer/dart/ast/token.dart'; | 8 import 'package:analyzer/dart/ast/token.dart'; |
| 9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
| 10 import 'package:analyzer/dart/element/type.dart'; | 10 import 'package:analyzer/dart/element/type.dart'; |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 if (!_isCandidateToken(entity.endToken, offset)) { | 192 if (!_isCandidateToken(entity.endToken, offset)) { |
| 193 continue; | 193 continue; |
| 194 } | 194 } |
| 195 | 195 |
| 196 // If the node is a candidate target, then we are done. | 196 // If the node is a candidate target, then we are done. |
| 197 if (_isCandidateNode(entity, offset)) { | 197 if (_isCandidateNode(entity, offset)) { |
| 198 // Check to see if the offset is in a preceding comment | 198 // Check to see if the offset is in a preceding comment |
| 199 Token commentToken = | 199 Token commentToken = |
| 200 _getContainingCommentToken(entity.beginToken, offset); | 200 _getContainingCommentToken(entity.beginToken, offset); |
| 201 if (commentToken != null) { | 201 if (commentToken != null) { |
| 202 entity = commentToken; | |
| 203 // If the preceding comment is dartdoc token, then update | 202 // If the preceding comment is dartdoc token, then update |
| 204 // the containing node to be the dartdoc comment. | 203 // the containing node to be the dartdoc comment. |
| 205 // Otherwise completion is not required. | 204 // Otherwise completion is not required. |
| 206 Comment docComment = | 205 Comment docComment = |
| 207 _getContainingDocComment(containingNode, commentToken); | 206 _getContainingDocComment(containingNode, commentToken); |
| 208 if (docComment != null) { | 207 if (docComment != null) { |
| 209 containingNode = docComment; | 208 return new CompletionTarget._( |
| 209 compilationUnit, offset, docComment, commentToken, false); |
| 210 } else { | 210 } else { |
| 211 return new CompletionTarget._(compilationUnit, offset, | 211 return new CompletionTarget._(compilationUnit, offset, |
| 212 compilationUnit, commentToken, true); | 212 compilationUnit, commentToken, true); |
| 213 } | 213 } |
| 214 } | 214 } |
| 215 return new CompletionTarget._( | 215 return new CompletionTarget._( |
| 216 compilationUnit, offset, containingNode, entity, false); | 216 compilationUnit, offset, containingNode, entity, false); |
| 217 } | 217 } |
| 218 | 218 |
| 219 // Otherwise, the completion target is somewhere inside the entity, | 219 // Otherwise, the completion target is somewhere inside the entity, |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 if (param.parameterKind == ParameterKind.NAMED) { | 423 if (param.parameterKind == ParameterKind.NAMED) { |
| 424 // TODO(danrubel) handle named parameters | 424 // TODO(danrubel) handle named parameters |
| 425 return false; | 425 return false; |
| 426 } else { | 426 } else { |
| 427 return paramType is FunctionType || paramType is FunctionTypeAlias; | 427 return paramType is FunctionType || paramType is FunctionTypeAlias; |
| 428 } | 428 } |
| 429 } | 429 } |
| 430 return false; | 430 return false; |
| 431 } | 431 } |
| 432 } | 432 } |
| OLD | NEW |