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

Side by Side Diff: pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart

Issue 2944083002: Handle unresolved constructor (issue 29925) (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 import 'package:analyzer/dart/ast/ast.dart'; 5 import 'package:analyzer/dart/ast/ast.dart';
6 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; 6 import 'package:analyzer/dart/ast/standard_resolution_map.dart';
7 import 'package:analyzer/dart/ast/token.dart'; 7 import 'package:analyzer/dart/ast/token.dart';
8 import 'package:analyzer/dart/ast/visitor.dart'; 8 import 'package:analyzer/dart/ast/visitor.dart';
9 import 'package:analyzer/dart/element/element.dart'; 9 import 'package:analyzer/dart/element/element.dart';
10 import 'package:analyzer/dart/element/type.dart'; 10 import 'package:analyzer/dart/element/type.dart';
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after
731 return relevance; 731 return relevance;
732 } 732 }
733 }; 733 };
734 optype.includeTypeNameSuggestions = true; 734 optype.includeTypeNameSuggestions = true;
735 735
736 // Check for named parameters in constructor calls. 736 // Check for named parameters in constructor calls.
737 AstNode grandparent = node.parent.parent; 737 AstNode grandparent = node.parent.parent;
738 if (grandparent is ConstructorReferenceNode) { 738 if (grandparent is ConstructorReferenceNode) {
739 ConstructorElement element = 739 ConstructorElement element =
740 (grandparent as ConstructorReferenceNode).staticElement; 740 (grandparent as ConstructorReferenceNode).staticElement;
741 List<ParameterElement> parameters = element.parameters; 741 if (element != null) {
742 ParameterElement parameterElement = parameters.firstWhere((e) { 742 List<ParameterElement> parameters = element.parameters;
743 if (e is DefaultFieldFormalParameterElementImpl) { 743 ParameterElement parameterElement = parameters.firstWhere((e) {
744 return e.field.name == node.name.label.name; 744 if (e is DefaultFieldFormalParameterElementImpl) {
745 return e.field.name == node.name.label.name;
746 }
747 return e.parameterKind == ParameterKind.NAMED &&
748 e.name == node.name.label.name;
749 }, orElse: () => null);
750 // Suggest tear-offs.
751 if (parameterElement?.type is FunctionType) {
752 optype.includeVoidReturnSuggestions = true;
745 } 753 }
746 return e.parameterKind == ParameterKind.NAMED &&
747 e.name == node.name.label.name;
748 }, orElse: () => null);
749 // Suggest tear-offs.
750 if (parameterElement?.type is FunctionType) {
751 optype.includeVoidReturnSuggestions = true;
752 } 754 }
753 } 755 }
754 } 756 }
755 } 757 }
756 758
757 @override 759 @override
758 void visitNode(AstNode node) { 760 void visitNode(AstNode node) {
759 // no suggestion by default 761 // no suggestion by default
760 } 762 }
761 763
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
975 } 977 }
976 978
977 bool _isEntityPrevTokenSynthetic() { 979 bool _isEntityPrevTokenSynthetic() {
978 Object entity = this.entity; 980 Object entity = this.entity;
979 if (entity is AstNode && entity.beginToken.previous?.isSynthetic ?? false) { 981 if (entity is AstNode && entity.beginToken.previous?.isSynthetic ?? false) {
980 return true; 982 return true;
981 } 983 }
982 return false; 984 return false;
983 } 985 }
984 } 986 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698