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

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

Issue 1099583002: fix NSM when computing field formal parameter in non-constructor arg list (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 8 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/completion_test_util.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/prefixed_element_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart b/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
index b878cb663f3da2f8a5f029dc6948eaa3627cd7ff..296ca24440c9aa38ae119004c7d55b445cd8420b 100644
--- a/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
@@ -91,38 +91,40 @@ class _FieldFormalSuggestionBuilder implements SuggestionBuilder {
@override
bool computeFast(AstNode node) {
if (node is FieldFormalParameter) {
-
- // Compute fields already referenced
ConstructorDeclaration constructorDecl =
node.getAncestor((p) => p is ConstructorDeclaration);
- List<String> referencedFields = new List<String>();
- for (FormalParameter param in constructorDecl.parameters.parameters) {
- if (param is FieldFormalParameter) {
- SimpleIdentifier fieldId = param.identifier;
- if (fieldId != null && fieldId != request.target.entity) {
- String fieldName = fieldId.name;
- if (fieldName != null && fieldName.length > 0) {
- referencedFields.add(fieldName);
+ if (constructorDecl != null) {
+
+ // Compute fields already referenced
+ List<String> referencedFields = new List<String>();
+ for (FormalParameter param in constructorDecl.parameters.parameters) {
+ if (param is FieldFormalParameter) {
+ SimpleIdentifier fieldId = param.identifier;
+ if (fieldId != null && fieldId != request.target.entity) {
+ String fieldName = fieldId.name;
+ if (fieldName != null && fieldName.length > 0) {
+ referencedFields.add(fieldName);
+ }
}
}
}
- }
- // Add suggestions for fields that are not already referenced
- ClassDeclaration classDecl =
- constructorDecl.getAncestor((p) => p is ClassDeclaration);
- for (ClassMember member in classDecl.members) {
- if (member is FieldDeclaration) {
- for (VariableDeclaration varDecl in member.fields.variables) {
- SimpleIdentifier fieldId = varDecl.name;
- if (fieldId != null) {
- String fieldName = fieldId.name;
- if (fieldName != null && fieldName.length > 0) {
- if (!referencedFields.contains(fieldName)) {
- CompletionSuggestion suggestion =
- createFieldSuggestion(member, varDecl);
- if (suggestion != null) {
- request.addSuggestion(suggestion);
+ // Add suggestions for fields that are not already referenced
+ ClassDeclaration classDecl =
+ constructorDecl.getAncestor((p) => p is ClassDeclaration);
+ for (ClassMember member in classDecl.members) {
+ if (member is FieldDeclaration) {
+ for (VariableDeclaration varDecl in member.fields.variables) {
+ SimpleIdentifier fieldId = varDecl.name;
+ if (fieldId != null) {
+ String fieldName = fieldId.name;
+ if (fieldName != null && fieldName.length > 0) {
+ if (!referencedFields.contains(fieldName)) {
+ CompletionSuggestion suggestion =
+ createFieldSuggestion(member, varDecl);
+ if (suggestion != null) {
+ request.addSuggestion(suggestion);
+ }
}
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/completion_test_util.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698