@@ -17,15 +17,14 @@ import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dar
17
17
/// An object that can compute a refactoring in a Dart file.
18
18
abstract class RefactoringProducer {
19
19
/// The context in which the refactoring was requested.
20
- final RefactoringContext _context ;
20
+ final RefactoringContext refactoringContext ;
21
21
22
- /// Initialize a newly created refactoring producer to create a refactoring in
23
- /// the given [_context] .
24
- RefactoringProducer (this ._context);
22
+ /// Initialize a newly created refactoring producer.
23
+ RefactoringProducer (this .refactoringContext);
25
24
26
25
/// The most deeply nested node whose range completely includes the range of
27
26
/// characters described by [selectionOffset] and [selectionLength] .
28
- AstNode ? get coveringNode => _context .coveringNode;
27
+ AstNode ? get coveringNode => refactoringContext .coveringNode;
29
28
30
29
/// Return whether this refactor is considered experimental and will only
31
30
/// be included if the user has opted-in.
@@ -39,47 +38,50 @@ abstract class RefactoringProducer {
39
38
40
39
/// Return the result of resolving the library in which the refactoring was
41
40
/// invoked.
42
- ResolvedLibraryResult get libraryResult => _context.resolvedLibraryResult;
41
+ ResolvedLibraryResult get libraryResult {
42
+ return refactoringContext.resolvedLibraryResult;
43
+ }
43
44
44
45
/// Return a list of the parameters to send to the client.
45
46
List <CommandParameter > get parameters;
46
47
47
- RefactoringContext get refactoringContext => _context;
48
-
49
48
/// Return the search engine used to search outside the resolved library.
50
- SearchEngine get searchEngine => _context .searchEngine;
49
+ SearchEngine get searchEngine => refactoringContext .searchEngine;
51
50
52
51
/// Return the selection, or `null` if the selection is not valid.
53
- Selection ? get selection => _context .selection;
52
+ Selection ? get selection => refactoringContext .selection;
54
53
55
54
/// Return the offset of the first character after the selection range.
56
- int get selectionEnd => _context .selectionEnd;
55
+ int get selectionEnd => refactoringContext .selectionEnd;
57
56
58
57
/// Return the number of selected characters.
59
- int get selectionLength => _context .selectionLength;
58
+ int get selectionLength => refactoringContext .selectionLength;
60
59
61
60
/// Return the offset of the beginning of the selection range.
62
- int get selectionOffset => _context .selectionOffset;
61
+ int get selectionOffset => refactoringContext .selectionOffset;
63
62
64
63
/// Return the helper used to efficiently access resolved units.
65
- AnalysisSessionHelper get sessionHelper => _context .sessionHelper;
64
+ AnalysisSessionHelper get sessionHelper => refactoringContext .sessionHelper;
66
65
67
66
/// Return `true` if the client has support for creating files. Subclasses
68
67
/// that require the ability to create new files must not create a refactoring
69
68
/// if this getter returns `false` .
70
- bool get supportsFileCreation =>
71
- _context.server.clientCapabilities? .documentChanges == true &&
72
- _context.server.clientCapabilities? .createResourceOperations == true ;
69
+ bool get supportsFileCreation {
70
+ final capabilities = refactoringContext.server.clientCapabilities;
71
+ return capabilities != null &&
72
+ capabilities.documentChanges == true &&
73
+ capabilities.createResourceOperations == true ;
74
+ }
73
75
74
76
/// Return the title of this refactoring.
75
77
String get title;
76
78
77
79
/// Return the result of resolving the file in which the refactoring was
78
80
/// invoked.
79
- ResolvedUnitResult get unitResult => _context .resolvedUnitResult;
81
+ ResolvedUnitResult get unitResult => refactoringContext .resolvedUnitResult;
80
82
81
83
/// Return the correction utilities for this refactoring.
82
- CorrectionUtils get utils => _context .utils;
84
+ CorrectionUtils get utils => refactoringContext .utils;
83
85
84
86
/// Given the [commandArguments] associated with the command, use the
85
87
/// [builder] to generate the edits necessary to apply this refactoring.
@@ -89,15 +91,17 @@ abstract class RefactoringProducer {
89
91
bool isAvailable ();
90
92
91
93
/// Return `true` if the selection is inside the given [token] .
92
- bool selectionIsInToken (Token ? token) => _context.selectionIsInToken (token);
94
+ bool selectionIsInToken (Token ? token) {
95
+ return refactoringContext.selectionIsInToken (token);
96
+ }
93
97
94
98
/// Return `true` if the client has support for command parameters of the
95
99
/// provided `kind` . Subclasses that produce command parameters of this kind
96
100
/// that don't have a default value must not create a refactoring if this
97
101
/// returns `false` .
98
- bool supportsCommandParameter (String kind) =>
99
- _context
100
- .server.clientCapabilities ? .codeActionCommandParameterSupportedKinds
101
- . contains (kind) ??
102
- false ;
102
+ bool supportsCommandParameter (String kind) {
103
+ final capabilities = refactoringContext.server.clientCapabilities;
104
+ return capabilities != null &&
105
+ capabilities.codeActionCommandParameterSupportedKinds. contains (kind);
106
+ }
103
107
}
0 commit comments