Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1001)

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/optype.dart

Issue 1963323003: More tweaks for 'for' completion. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698