@@ -14,35 +14,41 @@ class CompletionState {
14
14
/// The completion request being processed.
15
15
final DartCompletionRequest request;
16
16
17
- /// The selection at the time completion was requested. The selection is
18
- /// required to have a length of zero.
17
+ /// The selection at the time completion was requested.
18
+ ///
19
+ /// The selection is required to have a length of zero.
19
20
final Selection selection;
20
21
22
+ /// The budget controlling how much time can be spent computing completion
23
+ /// suggestions.
24
+ final CompletionBudget budget;
25
+
21
26
/// Initialize a newly created completion state.
22
- CompletionState (this .request, this .selection) : assert (selection.length == 0 );
27
+ CompletionState (this .request, this .selection, this .budget)
28
+ : assert (selection.length == 0 );
23
29
24
- /// Returns the type of value required by the context in which completion was
30
+ /// The type of value required by the context in which completion was
25
31
/// requested.
26
32
DartType ? get contextType => request.contextType;
27
33
28
- /// Return the [ClassMember] that encloses the completion location, or `null`
29
- /// if the completion location isn't in a class member.
34
+ /// The [ClassMember] that encloses the completion location, or `null` if the
35
+ /// completion location isn't in a class member.
30
36
ClassMember ? get enclosingMember {
31
37
return selection.coveringNode.thisOrAncestorOfType <ClassMember >();
32
38
}
33
39
34
- /// Return `true` if the completion location is inside an instance member, and
35
- /// hence there is a binding for `this` .
40
+ /// Whether the completion location is inside an instance member, and hence
41
+ /// whether there is a binding for `this` .
36
42
bool get inInstanceScope {
37
43
var member = enclosingMember;
38
44
return member != null && ! member.isStatic;
39
45
}
40
46
41
- /// Returns the element of the library containing the completion location.
47
+ /// The element of the library containing the completion location.
42
48
LibraryElement get libraryElement => request.libraryElement;
43
49
44
- /// Return the type of `this` at the completion location, or `null`
45
- /// if the completion location doesn't allow `this` to be used.
50
+ /// The type of `this` at the completion location, or `null` if the completion
51
+ /// location doesn't allow `this` to be used.
46
52
DartType ? get thisType {
47
53
AstNode ? node = selection.coveringNode;
48
54
while (node != null ) {
@@ -70,16 +76,16 @@ class CompletionState {
70
76
return null ;
71
77
}
72
78
73
- /// Return `true` if the given `feature` is enabled in the library containing
74
- /// the selection.
79
+ /// Whether the given `feature` is enabled in the library containing the
80
+ /// selection.
75
81
bool isFeatureEnabled (Feature feature) {
76
82
return libraryElement.featureSet.isEnabled (feature);
77
83
}
78
84
}
79
85
80
86
// TODO(brianwilkerson): Move to 'package:analysis_server/src/utilities/extensions/ast.dart'
81
87
extension on ClassMember {
82
- /// Return `true` if this member is a static member.
88
+ /// Whether this member is a static member.
83
89
bool get isStatic {
84
90
var self = this ;
85
91
if (self is MethodDeclaration ) {
0 commit comments