Skip to content

Commit 8a08c1b

Browse files
committed
[element model] migrate session_helper API
Change-Id: Ia2717bb24c83a409e853fb5271a3d5ed91cd3306 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/402142 Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 9f3e0cf commit 8a08c1b

35 files changed

+107
-222
lines changed

pkg/analysis_server/lib/src/lsp/handlers/handler_document_color_presentation.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class DocumentColorPresentationHandler
158158
var editRange = SourceRange(editStart, editEnd - editStart);
159159

160160
var sessionHelper = AnalysisSessionHelper(unit.session);
161-
var colorType = await sessionHelper.getFlutterClass2('Color');
161+
var colorType = await sessionHelper.getFlutterClass('Color');
162162
if (colorType == null) {
163163
// If we can't find the class (perhaps because this isn't a Flutter
164164
// project) we will not include any results. In theory the client should

pkg/analysis_server/lib/src/services/correction/dart/add_enum_constant.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AddEnumConstant extends ResolvedCorrectionProducer {
4242
if (targetElement.library2.isInSdk) return;
4343

4444
var targetFragment = targetElement.firstFragment;
45-
var targetDeclarationResult = await sessionHelper.getElementDeclaration2(
45+
var targetDeclarationResult = await sessionHelper.getElementDeclaration(
4646
targetFragment,
4747
);
4848
if (targetDeclarationResult == null) return;

pkg/analysis_server/lib/src/services/correction/dart/add_key_to_constructors.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class AddKeyToConstructors extends ResolvedCorrectionProducer {
167167

168168
/// Return the type for the class `Key`.
169169
Future<DartType?> _getKeyType() async {
170-
var keyClass = await sessionHelper.getFlutterClass2('Key');
170+
var keyClass = await sessionHelper.getFlutterClass('Key');
171171
if (keyClass == null) {
172172
return null;
173173
}

pkg/analysis_server/lib/src/services/correction/dart/add_late.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class AddLate extends ResolvedCorrectionProducer {
6969
!variableElement.isLate &&
7070
variableElement.setter2 == null) {
7171
var variableFragment = variableElement.firstFragment;
72-
var declarationResult = await sessionHelper.getElementDeclaration2(
72+
var declarationResult = await sessionHelper.getElementDeclaration(
7373
variableFragment,
7474
);
7575
if (declarationResult == null) {

pkg/analysis_server/lib/src/services/correction/dart/create_constructor.dart

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class CreateConstructor extends ResolvedCorrectionProducer {
8989
// prepare target ClassDeclaration
9090
var targetElement = targetType.element3;
9191
var targetFragment = targetElement.firstFragment;
92-
var targetResult = await sessionHelper.getElementDeclaration2(
92+
var targetResult = await sessionHelper.getElementDeclaration(
9393
targetFragment,
9494
);
9595
if (targetResult == null) {
@@ -130,9 +130,7 @@ class CreateConstructor extends ResolvedCorrectionProducer {
130130
}
131131

132132
// prepare target interface type
133-
var targetResult = await sessionHelper.getElementDeclaration2(
134-
targetElement,
135-
);
133+
var targetResult = await sessionHelper.getElementDeclaration(targetElement);
136134
if (targetResult == null) {
137135
return;
138136
}
@@ -185,7 +183,7 @@ class CreateConstructor extends ResolvedCorrectionProducer {
185183
}
186184

187185
// prepare target ClassDeclaration
188-
var targetResult = await sessionHelper.getElementDeclaration2(
186+
var targetResult = await sessionHelper.getElementDeclaration(
189187
targetFragment,
190188
);
191189
if (targetResult == null) {

pkg/analysis_server/lib/src/services/correction/dart/create_constructor_for_final_fields.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class CreateConstructorForFinalFields extends ResolvedCorrectionProducer {
155155
required _FixContext fixContext,
156156
required NamedCompilationUnitMember classDeclaration,
157157
}) async {
158-
var keyClass = await sessionHelper.getFlutterClass2('Key');
158+
var keyClass = await sessionHelper.getFlutterClass('Key');
159159
if (keyClass == null) {
160160
return;
161161
}

pkg/analysis_server/lib/src/services/correction/dart/create_field.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class CreateField extends CreateFieldOrGetter {
7676
}
7777
// Prepare target `ClassDeclaration`.
7878
var targetFragment = targetElement.firstFragment;
79-
var targetDeclarationResult = await sessionHelper.getElementDeclaration2(
79+
var targetDeclarationResult = await sessionHelper.getElementDeclaration(
8080
targetFragment,
8181
);
8282
if (targetDeclarationResult == null) {

pkg/analysis_server/lib/src/services/correction/dart/create_getter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class CreateGetter extends CreateFieldOrGetter {
198198
return;
199199
}
200200
// prepare target declaration
201-
var targetDeclarationResult = await sessionHelper.getElementDeclaration2(
201+
var targetDeclarationResult = await sessionHelper.getElementDeclaration(
202202
targetFragment,
203203
);
204204
if (targetDeclarationResult == null) {

pkg/analysis_server/lib/src/services/correction/dart/create_method.dart

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,15 @@ class CreateMethod extends ResolvedCorrectionProducer {
105105
if (target is ExtensionOverride) {
106106
targetFragment = target.element2.firstFragment;
107107
if (targetFragment is ExtensionFragment) {
108-
targetNode = await getExtensionDeclaration2(targetFragment);
108+
targetNode = await getExtensionDeclaration(targetFragment);
109109
if (targetNode == null) {
110110
return;
111111
}
112112
}
113113
} else if (target is Identifier && target.element is ExtensionElement2) {
114114
targetFragment = (target.element as ExtensionElement2).firstFragment;
115115
if (targetFragment is ExtensionFragment) {
116-
targetNode = await getExtensionDeclaration2(targetFragment);
116+
targetNode = await getExtensionDeclaration(targetFragment);
117117
if (targetNode == null) {
118118
return;
119119
}
@@ -144,13 +144,13 @@ class CreateMethod extends ResolvedCorrectionProducer {
144144
// Prepare target ClassDeclaration.
145145
if (targetClassElement is MixinElement2) {
146146
var fragment = targetClassElement.firstFragment;
147-
targetNode = await getMixinDeclaration2(fragment);
147+
targetNode = await getMixinDeclaration(fragment);
148148
} else if (targetClassElement is ClassElement2) {
149149
var fragment = targetClassElement.firstFragment;
150-
targetNode = await getClassDeclaration2(fragment);
150+
targetNode = await getClassDeclaration(fragment);
151151
} else if (targetClassElement is ExtensionTypeElement2) {
152152
var fragment = targetClassElement.firstFragment;
153-
targetNode = await getExtensionTypeDeclaration2(fragment);
153+
targetNode = await getExtensionTypeDeclaration(fragment);
154154
}
155155
if (targetNode == null) {
156156
return;

pkg/analysis_server/lib/src/services/correction/dart/create_method_or_function.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,11 @@ class CreateMethodOrFunction extends ResolvedCorrectionProducer {
203203
List<ClassMember>? classMembers;
204204
if (targetClassElement is MixinElement2) {
205205
var fragment = targetClassElement.firstFragment;
206-
var node = targetNode = await getMixinDeclaration2(fragment);
206+
var node = targetNode = await getMixinDeclaration(fragment);
207207
classMembers = node?.members;
208208
} else if (targetClassElement is ClassElement2) {
209209
var fragment = targetClassElement.firstFragment;
210-
var node = targetNode = await getClassDeclaration2(fragment);
210+
var node = targetNode = await getClassDeclaration(fragment);
211211
classMembers = node?.members;
212212
}
213213
if (targetNode == null || classMembers == null) {

0 commit comments

Comments
 (0)