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

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

Issue 1960783002: Don't suggest types, getters, etc in 'for (Type ^)'. (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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 80b98d8b6e59efb751377834662814a6464c27b3..60bc8134ce2a8dc980a5a68ecaee9cecdeebd8cf 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/optype.dart
@@ -464,17 +464,25 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
@override
void visitForStatement(ForStatement node) {
+ var entity = this.entity;
if (_isEntityPrevTokenSynthetic()) {
// Actual: for (var v i^)
// Parsed: for (var i; i^;)
- return;
+ } else if (entity is Token &&
+ entity.isSynthetic &&
+ node.leftSeparator == entity) {
+ // Actual: for (String ^)
+ // Parsed: for (String; ;)
+ // ^
+ 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.
}
- 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.
}
@override
@@ -504,8 +512,7 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
if (_isEntityPrevTokenSynthetic()) {
// Actual: if (var v i^)
// Parsed: if (v) i^;
- } else if (identical(
- entity, node.condition)) {
+ } else if (identical(entity, node.condition)) {
optype.includeReturnValueSuggestions = true;
optype.includeTypeNameSuggestions = true;
} else if (identical(entity, node.thenStatement) ||
@@ -848,8 +855,7 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor {
bool _isEntityPrevTokenSynthetic() {
Object entity = this.entity;
- if (entity is AstNode && entity.beginToken.previous?.isSynthetic ??
- false) {
+ if (entity is AstNode && entity.beginToken.previous?.isSynthetic ?? false) {
return true;
}
return false;
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/dart/imported_reference_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698