| 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_services/completion/completion_computer.dart'; | 9 import 'package:analysis_services/completion/completion_computer.dart'; |
| 10 import 'package:analysis_services/completion/completion_suggestion.dart'; | 10 import 'package:analysis_services/completion/completion_suggestion.dart'; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 visitBlock(Block node) { | 80 visitBlock(Block node) { |
| 81 node.statements.forEach((Statement stmt) { | 81 node.statements.forEach((Statement stmt) { |
| 82 if (stmt.offset < offset) { | 82 if (stmt.offset < offset) { |
| 83 if (stmt is LabeledStatement) { | 83 if (stmt is LabeledStatement) { |
| 84 stmt.labels.forEach((Label label) { | 84 stmt.labels.forEach((Label label) { |
| 85 // addSuggestion(label.label, CompletionSuggestionKind.LABEL); | 85 // addSuggestion(label.label, CompletionSuggestionKind.LABEL); |
| 86 }); | 86 }); |
| 87 } else if (stmt is VariableDeclarationStatement) { | 87 } else if (stmt is VariableDeclarationStatement) { |
| 88 stmt.variables.variables.forEach((VariableDeclaration varDecl) { | 88 stmt.variables.variables.forEach((VariableDeclaration varDecl) { |
| 89 if (varDecl.end < offset) { | 89 if (varDecl.end < offset) { |
| 90 addSuggestion(varDecl.name, CompletionSuggestionKind.VARIABLE); | 90 addSuggestion( |
| 91 varDecl.name, |
| 92 CompletionSuggestionKind.LOCAL_VARIABLE); |
| 91 } | 93 } |
| 92 }); | 94 }); |
| 93 } | 95 } |
| 94 } | 96 } |
| 95 }); | 97 }); |
| 96 visitNode(node); | 98 visitNode(node); |
| 97 } | 99 } |
| 98 | 100 |
| 99 visitCatchClause(CatchClause node) { | 101 visitCatchClause(CatchClause node) { |
| 100 addSuggestion(node.exceptionParameter, CompletionSuggestionKind.PARAMETER); | 102 addSuggestion(node.exceptionParameter, CompletionSuggestionKind.PARAMETER); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 addSuggestion(declaration.name, CompletionSuggestionKind.CLASS_ALIAS); | 138 addSuggestion(declaration.name, CompletionSuggestionKind.CLASS_ALIAS); |
| 137 } else if (declaration is FunctionTypeAlias) { | 139 } else if (declaration is FunctionTypeAlias) { |
| 138 addSuggestion( | 140 addSuggestion( |
| 139 declaration.name, | 141 declaration.name, |
| 140 CompletionSuggestionKind.FUNCTION_TYPE_ALIAS); | 142 CompletionSuggestionKind.FUNCTION_TYPE_ALIAS); |
| 141 } | 143 } |
| 142 }); | 144 }); |
| 143 } | 145 } |
| 144 | 146 |
| 145 visitForEachStatement(ForEachStatement node) { | 147 visitForEachStatement(ForEachStatement node) { |
| 146 addSuggestion(node.identifier, CompletionSuggestionKind.VARIABLE); | 148 addSuggestion(node.identifier, CompletionSuggestionKind.LOCAL_VARIABLE); |
| 147 visitNode(node); | 149 visitNode(node); |
| 148 } | 150 } |
| 149 | 151 |
| 150 visitForStatement(ForStatement node) { | 152 visitForStatement(ForStatement node) { |
| 151 addSuggestions(node.variables, CompletionSuggestionKind.VARIABLE); | 153 addSuggestions(node.variables, CompletionSuggestionKind.LOCAL_VARIABLE); |
| 152 visitNode(node); | 154 visitNode(node); |
| 153 } | 155 } |
| 154 | 156 |
| 155 visitFunctionDeclaration(FunctionDeclaration node) { | 157 visitFunctionDeclaration(FunctionDeclaration node) { |
| 156 // This is added by the compilation unit containing it | 158 // This is added by the compilation unit containing it |
| 157 //addSuggestion(node.name, CompletionSuggestionKind.FUNCTION); | 159 //addSuggestion(node.name, CompletionSuggestionKind.FUNCTION); |
| 158 visitNode(node); | 160 visitNode(node); |
| 159 } | 161 } |
| 160 | 162 |
| 161 visitFunctionExpression(FunctionExpression node) { | 163 visitFunctionExpression(FunctionExpression node) { |
| 162 node.parameters.parameters.forEach((FormalParameter param) { | 164 node.parameters.parameters.forEach((FormalParameter param) { |
| 163 addSuggestion(param.identifier, CompletionSuggestionKind.PARAMETER); | 165 addSuggestion(param.identifier, CompletionSuggestionKind.PARAMETER); |
| 164 }); | 166 }); |
| 165 visitNode(node); | 167 visitNode(node); |
| 166 } | 168 } |
| 167 | 169 |
| 168 visitMethodDeclaration(MethodDeclaration node) { | 170 visitMethodDeclaration(MethodDeclaration node) { |
| 169 node.parameters.parameters.forEach((FormalParameter param) { | 171 node.parameters.parameters.forEach((FormalParameter param) { |
| 170 if (param.identifier != null) { | 172 if (param.identifier != null) { |
| 171 addSuggestion(param.identifier, CompletionSuggestionKind.PARAMETER); | 173 addSuggestion(param.identifier, CompletionSuggestionKind.PARAMETER); |
| 172 } | 174 } |
| 173 }); | 175 }); |
| 174 visitNode(node); | 176 visitNode(node); |
| 175 } | 177 } |
| 176 | 178 |
| 177 visitNode(AstNode node) { | 179 visitNode(AstNode node) { |
| 178 node.parent.accept(this); | 180 node.parent.accept(this); |
| 179 } | 181 } |
| 180 } | 182 } |
| OLD | NEW |