OLD | NEW |
---|---|
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 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.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 26 matching lines...) Expand all Loading... | |
37 new CompletionTarget.forOffset(request.result.unit, request.offset); | 37 new CompletionTarget.forOffset(request.result.unit, request.offset); |
38 OpType optype = new OpType.forCompletion(target, request.offset); | 38 OpType optype = new OpType.forCompletion(target, request.offset); |
39 if (!optype.includeIdentifiers) { | 39 if (!optype.includeIdentifiers) { |
40 return; | 40 return; |
41 } | 41 } |
42 ClassDeclaration classDecl = _enclosingClass(target); | 42 ClassDeclaration classDecl = _enclosingClass(target); |
43 if (classDecl == null || classDecl.element == null) { | 43 if (classDecl == null || classDecl.element == null) { |
44 return; | 44 return; |
45 } | 45 } |
46 containingLibrary = request.result.libraryElement; | 46 containingLibrary = request.result.libraryElement; |
47 _computeSuggestionsForClass2( | 47 _computeSuggestionsForClass2(collector, target, |
48 collector, | 48 resolutionMap.elementDeclaredByClassDeclaration(classDecl), optype); |
49 target, | 49 } |
50 resolutionMap.elementDeclaredByClassDeclaration(classDecl), | 50 |
51 request, | 51 Future<Null> computeSuggestionsForClass( |
mfairhurst
2017/06/13 20:31:39
Could use a comment that this is here for our use
maxkim
2017/06/13 20:49:22
Acknowledged.
Brian Wilkerson
2017/06/13 20:50:19
Is this a short-term work-around until you can jus
maxkim
2017/06/13 21:11:40
This is intended to be long-term and I'll write up
| |
52 optype); | 52 CompletionRequest request, |
53 CompletionCollector collector, | |
54 ClassElement classElement, { | |
55 AstNode entryPoint, | |
56 bool skipChildClass, | |
57 OpType optype, | |
58 }) async { | |
59 CompletionTarget target = new CompletionTarget.forOffset( | |
mfairhurst
2017/06/13 20:31:39
I would assume that we would want to pass in a Com
maxkim
2017/06/13 20:49:22
Acknowledged.
| |
60 request.result.unit, request.offset, | |
61 entryPoint: entryPoint); | |
62 optype ??= new OpType.forCompletion(target, request.offset); | |
63 if (!optype.includeIdentifiers) { | |
64 return; | |
65 } | |
66 if (classElement == null) { | |
67 ClassDeclaration classDecl = _enclosingClass(target); | |
68 if (classDecl == null || classDecl.element == null) { | |
69 return; | |
70 } | |
71 classElement = resolutionMap.elementDeclaredByClassDeclaration(classDecl); | |
72 } | |
73 containingLibrary = request.result.libraryElement; | |
74 _computeSuggestionsForClass2(collector, target, classElement, optype, | |
75 skipChildClass: skipChildClass); | |
53 } | 76 } |
54 | 77 |
55 _addSuggestionsForType(InterfaceType type, OpType optype, | 78 _addSuggestionsForType(InterfaceType type, OpType optype, |
56 {bool isFunctionalArgument: false}) { | 79 {bool isFunctionalArgument: false}) { |
57 if (!isFunctionalArgument) { | 80 if (!isFunctionalArgument) { |
58 for (PropertyAccessorElement elem in type.accessors) { | 81 for (PropertyAccessorElement elem in type.accessors) { |
59 if (elem.isGetter) { | 82 if (elem.isGetter) { |
60 if (optype.includeReturnValueSuggestions) { | 83 if (optype.includeReturnValueSuggestions) { |
61 addSuggestion(elem); | 84 addSuggestion(elem); |
62 } | 85 } |
(...skipping 12 matching lines...) Expand all Loading... | |
75 addSuggestion(elem); | 98 addSuggestion(elem); |
76 } | 99 } |
77 } else { | 100 } else { |
78 if (optype.includeVoidReturnSuggestions) { | 101 if (optype.includeVoidReturnSuggestions) { |
79 addSuggestion(elem); | 102 addSuggestion(elem); |
80 } | 103 } |
81 } | 104 } |
82 } | 105 } |
83 } | 106 } |
84 | 107 |
85 void _computeSuggestionsForClass2( | 108 void _computeSuggestionsForClass2(CompletionCollector collector, |
86 CompletionCollector collector, | 109 CompletionTarget target, ClassElement classElement, OpType optype, |
87 CompletionTarget target, | |
88 ClassElement classElement, | |
89 CompletionRequest request, | |
90 OpType optype, | |
91 {bool skipChildClass: true}) { | 110 {bool skipChildClass: true}) { |
92 bool isFunctionalArgument = target.isFunctionalArgument(); | 111 bool isFunctionalArgument = target.isFunctionalArgument(); |
93 kind = isFunctionalArgument | 112 kind = isFunctionalArgument |
94 ? CompletionSuggestionKind.IDENTIFIER | 113 ? CompletionSuggestionKind.IDENTIFIER |
95 : CompletionSuggestionKind.INVOCATION; | 114 : CompletionSuggestionKind.INVOCATION; |
96 | 115 |
97 if (!skipChildClass) { | 116 if (!skipChildClass) { |
98 _addSuggestionsForType(classElement.type, optype, | 117 _addSuggestionsForType(classElement.type, optype, |
99 isFunctionalArgument: isFunctionalArgument); | 118 isFunctionalArgument: isFunctionalArgument); |
100 } | 119 } |
(...skipping 26 matching lines...) Expand all Loading... | |
127 if (node is FieldDeclaration) { | 146 if (node is FieldDeclaration) { |
128 if (node.isStatic) { | 147 if (node.isStatic) { |
129 return null; | 148 return null; |
130 } | 149 } |
131 } | 150 } |
132 node = node.parent; | 151 node = node.parent; |
133 } | 152 } |
134 return null; | 153 return null; |
135 } | 154 } |
136 } | 155 } |
OLD | NEW |