| 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.completion.computer.dart.local; | 5 library services.completion.computer.dart.local; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, | 9 import 'package:analysis_server/src/protocol.dart' as protocol show Element, |
| 10 ElementKind; | 10 ElementKind; |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 } | 78 } |
| 79 }); | 79 }); |
| 80 } | 80 } |
| 81 } | 81 } |
| 82 } | 82 } |
| 83 }); | 83 }); |
| 84 visitNode(node); | 84 visitNode(node); |
| 85 } | 85 } |
| 86 | 86 |
| 87 @override | 87 @override |
| 88 visitCombinator(Combinator node) { | |
| 89 // Handled by ImportedComputer | |
| 90 } | |
| 91 | |
| 92 @override | |
| 93 visitCascadeExpression(CascadeExpression node) { | 88 visitCascadeExpression(CascadeExpression node) { |
| 94 Expression target = node.target; | 89 Expression target = node.target; |
| 95 // This computer handles the expression | 90 // This computer handles the expression |
| 96 // while InvocationComputer handles the cascade selector | 91 // while InvocationComputer handles the cascade selector |
| 97 if (target != null && request.offset <= target.end) { | 92 if (target != null && request.offset <= target.end) { |
| 98 visitNode(node); | 93 visitNode(node); |
| 99 } | 94 } |
| 100 } | 95 } |
| 101 | 96 |
| 102 @override | 97 @override |
| 103 visitCatchClause(CatchClause node) { | 98 visitCatchClause(CatchClause node) { |
| 104 _addParamSuggestion(node.exceptionParameter, node.exceptionType); | 99 _addParamSuggestion(node.exceptionParameter, node.exceptionType); |
| 105 _addParamSuggestion(node.stackTraceParameter, STACKTRACE_TYPE); | 100 _addParamSuggestion(node.stackTraceParameter, STACKTRACE_TYPE); |
| 106 visitNode(node); | 101 visitNode(node); |
| 107 } | 102 } |
| 108 | 103 |
| 109 @override | 104 @override |
| 110 visitClassDeclaration(ClassDeclaration node) { | 105 visitClassDeclaration(ClassDeclaration node) { |
| 111 node.members.forEach((ClassMember classMbr) { | 106 node.members.forEach((ClassMember classMbr) { |
| 112 if (classMbr is FieldDeclaration) { | 107 if (classMbr is FieldDeclaration) { |
| 113 _addFieldSuggestions(node, classMbr); | 108 _addFieldSuggestions(node, classMbr); |
| 114 } else if (classMbr is MethodDeclaration) { | 109 } else if (classMbr is MethodDeclaration) { |
| 115 _addMethodSuggestion(node, classMbr); | 110 _addMethodSuggestion(node, classMbr); |
| 116 } | 111 } |
| 117 }); | 112 }); |
| 118 visitNode(node); | 113 visitNode(node); |
| 119 } | 114 } |
| 120 | 115 |
| 121 @override | 116 @override |
| 117 visitCombinator(Combinator node) { |
| 118 // Handled by ImportedComputer |
| 119 } |
| 120 |
| 121 @override |
| 122 visitCompilationUnit(CompilationUnit node) { | 122 visitCompilationUnit(CompilationUnit node) { |
| 123 node.declarations.forEach((Declaration declaration) { | 123 node.declarations.forEach((Declaration declaration) { |
| 124 if (declaration is ClassDeclaration) { | 124 if (declaration is ClassDeclaration) { |
| 125 _addClassSuggestion(declaration); | 125 _addClassSuggestion(declaration); |
| 126 } else if (declaration is EnumDeclaration) { | 126 } else if (declaration is EnumDeclaration) { |
| 127 // _addSuggestion(d.name, CompletionSuggestionKind.ENUM); | 127 // _addSuggestion(d.name, CompletionSuggestionKind.ENUM); |
| 128 } else if (declaration is FunctionDeclaration) { | 128 } else if (declaration is FunctionDeclaration) { |
| 129 _addFunctionSuggestion(declaration); | 129 _addFunctionSuggestion(declaration); |
| 130 } else if (declaration is TopLevelVariableDeclaration) { | 130 } else if (declaration is TopLevelVariableDeclaration) { |
| 131 _addTopLevelVarSuggestions(declaration.variables); | 131 _addTopLevelVarSuggestions(declaration.variables); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 visitNode(node); | 192 visitNode(node); |
| 193 } | 193 } |
| 194 | 194 |
| 195 @override | 195 @override |
| 196 visitFunctionExpression(FunctionExpression node) { | 196 visitFunctionExpression(FunctionExpression node) { |
| 197 _addParamListSuggestions(node.parameters); | 197 _addParamListSuggestions(node.parameters); |
| 198 visitNode(node); | 198 visitNode(node); |
| 199 } | 199 } |
| 200 | 200 |
| 201 @override | 201 @override |
| 202 visitInterpolationExpression(InterpolationExpression node) { |
| 203 visitNode(node); |
| 204 } |
| 205 |
| 206 @override |
| 202 visitMethodDeclaration(MethodDeclaration node) { | 207 visitMethodDeclaration(MethodDeclaration node) { |
| 203 _addParamListSuggestions(node.parameters); | 208 _addParamListSuggestions(node.parameters); |
| 204 visitNode(node); | 209 visitNode(node); |
| 205 } | 210 } |
| 206 | 211 |
| 207 @override | 212 @override |
| 208 visitNamespaceDirective(NamespaceDirective node) { | 213 visitNamespaceDirective(NamespaceDirective node) { |
| 209 // No suggestions | 214 // No suggestions |
| 210 } | 215 } |
| 211 | 216 |
| 212 @override | 217 @override |
| 213 visitNode(AstNode node) { | 218 visitNode(AstNode node) { |
| 214 node.parent.accept(this); | 219 node.parent.accept(this); |
| 215 } | 220 } |
| 216 | 221 |
| 217 @override | 222 @override |
| 218 visitPrefixedIdentifier(PrefixedIdentifier node) { | 223 visitPrefixedIdentifier(PrefixedIdentifier node) { |
| 219 // InvocationComputer adds suggestions for prefixed elements | 224 // InvocationComputer adds suggestions for prefixed elements |
| 220 // but this computer adds suggestions for the prefix itself | 225 // but this computer adds suggestions for the prefix itself |
| 221 SimpleIdentifier prefix = node.prefix; | 226 SimpleIdentifier prefix = node.prefix; |
| 222 if (prefix == null || request.offset <= prefix.end) { | 227 if (prefix == null || request.offset <= prefix.end) { |
| 223 visitNode(node); | 228 visitNode(node); |
| 224 } | 229 } |
| 225 } | 230 } |
| 226 | 231 |
| 227 @override | 232 @override |
| 233 visitStringLiteral(StringLiteral node) { |
| 234 // ignore |
| 235 } |
| 236 |
| 237 @override |
| 228 visitTypeName(TypeName node) { | 238 visitTypeName(TypeName node) { |
| 229 // If suggesting completions within a TypeName node | 239 // If suggesting completions within a TypeName node |
| 230 // then limit suggestions to only types | 240 // then limit suggestions to only types |
| 231 typesOnly = true; | 241 typesOnly = true; |
| 232 return visitNode(node); | 242 return visitNode(node); |
| 233 } | 243 } |
| 234 | 244 |
| 235 @override | 245 @override |
| 236 visitVariableDeclaration(VariableDeclaration node) { | 246 visitVariableDeclaration(VariableDeclaration node) { |
| 237 // Do not add suggestions if editing the name in a var declaration | 247 // Do not add suggestions if editing the name in a var declaration |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 if (name == null || name.length <= 0) { | 491 if (name == null || name.length <= 0) { |
| 482 return DYNAMIC; | 492 return DYNAMIC; |
| 483 } | 493 } |
| 484 TypeArgumentList typeArgs = type.typeArguments; | 494 TypeArgumentList typeArgs = type.typeArguments; |
| 485 if (typeArgs != null) { | 495 if (typeArgs != null) { |
| 486 //TODO (danrubel) include type arguments | 496 //TODO (danrubel) include type arguments |
| 487 } | 497 } |
| 488 return name; | 498 return name; |
| 489 } | 499 } |
| 490 } | 500 } |
| OLD | NEW |