Chromium Code Reviews| Index: pkg/analysis_server/lib/src/services/completion/dart/optype.dart |
| diff --git a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart |
| index 60bc8134ce2a8dc980a5a68ecaee9cecdeebd8cf..3ddc75dbf2f69eee9a7ec984a1e096db833e4327 100644 |
| --- a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart |
| +++ b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart |
| @@ -476,12 +476,24 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor { |
| // ^ |
| optype.includeVarNameSuggestions = true; |
| } else { |
| - optype.includeReturnValueSuggestions = true; |
| - optype.includeTypeNameSuggestions = true; |
| - optype.includeVoidReturnSuggestions = true; |
| - // TODO (danrubel) void return suggestions only belong after |
| - // the 2nd semicolon. Return value suggestions only belong after the |
| - // first or second semicolon. |
| + // for (^) {} |
| + // for (Str^ str = null;) {} |
| + // In theory it is possible to specify any expression in initializer, |
| + // but for any practical use we need only types. |
| + if (entity == node.initialization || entity == node.variables) { |
| + optype.includeTypeNameSuggestions = true; |
| + } |
| + // for (; ^) {} |
| + if (entity == node.condition) { |
| + optype.includeTypeNameSuggestions = true; |
|
Brian Wilkerson
2016/05/10 22:29:08
Seems unlikely to me that we'd want a type in eith
|
| + optype.includeReturnValueSuggestions = true; |
| + } |
| + // for (; ; ^) {} |
| + if (node.updaters.contains(entity)) { |
| + optype.includeTypeNameSuggestions = true; |
| + optype.includeReturnValueSuggestions = true; |
| + optype.includeVoidReturnSuggestions = true; |
| + } |
| } |
| } |
| @@ -853,6 +865,14 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor { |
| } |
| } |
| + bool _isEntityPrevToken(TokenType expectedType) { |
| + Object entity = this.entity; |
| + if (entity is SimpleIdentifier && entity.token.isSynthetic) { |
| + return entity.token.previous.type == expectedType; |
| + } |
| + return false; |
| + } |
| + |
| bool _isEntityPrevTokenSynthetic() { |
| Object entity = this.entity; |
| if (entity is AstNode && entity.beginToken.previous?.isSynthetic ?? false) { |