Skip to content

Commit 37848d1

Browse files
authored
Roll package:analyzer forward to 8.1.1 (flutter#173867)
1 parent f04e092 commit 37848d1

File tree

12 files changed

+80
-83
lines changed

12 files changed

+80
-83
lines changed

dev/bots/custom_rules/no_double_clamp.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class _DoubleClampVisitor extends RecursiveAstVisitor<void> {
6565

6666
@override
6767
void visitSimpleIdentifier(SimpleIdentifier node) {
68-
if (node.name != 'clamp' || node.staticElement is! MethodElement) {
68+
if (node.name != 'clamp' || node.element is! MethodElement) {
6969
return;
7070
}
7171
final bool isAllowed = switch (node.parent) {

dev/bots/custom_rules/no_stop_watches.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class _StopwatchVisitor extends RecursiveAstVisitor<void> {
9393
bool _isInternal(LibraryElement libraryElement) {
9494
return path.isWithin(
9595
compilationUnit.session.analysisContext.contextRoot.root.path,
96-
libraryElement.source.fullName,
96+
libraryElement.firstFragment.source.fullName,
9797
);
9898
}
9999

@@ -118,7 +118,7 @@ class _StopwatchVisitor extends RecursiveAstVisitor<void> {
118118

119119
@override
120120
void visitConstructorName(ConstructorName node) {
121-
final Element? element = node.staticElement;
121+
final Element? element = node.element;
122122
if (element is! ConstructorElement) {
123123
assert(false, '$element of $node is not a ConstructorElement.');
124124
return;
@@ -137,7 +137,7 @@ class _StopwatchVisitor extends RecursiveAstVisitor<void> {
137137

138138
@override
139139
void visitSimpleIdentifier(SimpleIdentifier node) {
140-
final bool isAllowed = switch (node.staticElement) {
140+
final bool isAllowed = switch (node.element) {
141141
ExecutableElement(
142142
returnType: DartType(element: final ClassElement classElement),
143143
library: final LibraryElement libraryElement,

dev/bots/custom_rules/protect_public_state_subtypes.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class _StateSubclassVisitor extends SimpleAstVisitor<void> {
7373

7474
@override
7575
void visitClassDeclaration(ClassDeclaration node) {
76-
if (isPublicStateSubtype(node.declaredElement!)) {
76+
if (isPublicStateSubtype(node.declaredFragment!.element)) {
7777
node.visitChildren(this);
7878
}
7979
}
@@ -92,7 +92,7 @@ class _StateSubclassVisitor extends SimpleAstVisitor<void> {
9292
case 'dispose':
9393
case 'build':
9494
case 'debugFillProperties':
95-
if (!node.declaredElement!.hasProtected) {
95+
if (!node.declaredFragment!.element.metadata.hasProtected) {
9696
unprotectedMethods.add(node);
9797
}
9898
}

dev/bots/custom_rules/render_box_intrinsics.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class _RenderBoxSubclassVisitor extends RecursiveAstVisitor<void> {
6666
// The cached version, call this method instead of _checkIfImplementsRenderBox.
6767
static bool _implementsRenderBox(InterfaceElement interfaceElement) {
6868
// Framework naming convention: a RenderObject subclass names have "Render" in its name.
69-
if (!interfaceElement.name.contains('Render')) {
69+
if (!interfaceElement.name!.contains('Render')) {
7070
return false;
7171
}
7272
return interfaceElement.name == 'RenderBox' ||
@@ -115,7 +115,7 @@ class _RenderBoxSubclassVisitor extends RecursiveAstVisitor<void> {
115115
if (isCallingSuperImplementation) {
116116
return;
117117
}
118-
final Element? declaredInClassElement = node.staticElement?.declaration?.enclosingElement3;
118+
final Element? declaredInClassElement = node.element?.enclosingElement;
119119
if (declaredInClassElement is InterfaceElement &&
120120
_implementsRenderBox(declaredInClassElement)) {
121121
violationNodes.add((node, correctMethodName));

packages/flutter_tools/lib/src/widget_preview/dependency_graph.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ class _PreviewVisitor extends RecursiveAstVisitor<void> {
9595
PreviewDetails(
9696
packageName: packageName,
9797
functionName: _currentFunction!.name.toString(),
98-
isBuilder: returnType.name2.isWidgetBuilder,
98+
isBuilder: returnType.name.isWidgetBuilder,
9999
previewAnnotation: preview,
100100
),
101101
);
@@ -117,7 +117,7 @@ class _PreviewVisitor extends RecursiveAstVisitor<void> {
117117
PreviewDetails(
118118
packageName: packageName,
119119
functionName: '${parentClass.name}.${_currentMethod!.name}',
120-
isBuilder: returnType.name2.isWidgetBuilder,
120+
isBuilder: returnType.name.isWidgetBuilder,
121121
previewAnnotation: preview,
122122
),
123123
);
@@ -134,7 +134,7 @@ class _PreviewVisitor extends RecursiveAstVisitor<void> {
134134

135135
/// Contains all the information related to a library being watched by [PreviewDetector].
136136
final class LibraryPreviewNode {
137-
LibraryPreviewNode({required LibraryElement2 library, required this.logger})
137+
LibraryPreviewNode({required LibraryElement library, required this.logger})
138138
: path = library.toPreviewPath() {
139139
final libraryFilePaths = <String>[
140140
for (final LibraryFragment fragment in library.fragments) fragment.source.fullName,
@@ -190,7 +190,7 @@ final class LibraryPreviewNode {
190190
/// Finds all previews defined in the [lib] and adds them to [previews].
191191
void findPreviews({required ResolvedLibraryResult lib}) {
192192
// Iterate over the compilation unit's AST to find previews.
193-
final visitor = _PreviewVisitor(lib: lib.element2);
193+
final visitor = _PreviewVisitor(lib: lib.element);
194194
for (final ResolvedUnitResult libUnit in lib.units) {
195195
libUnit.unit.visitChildren(visitor);
196196
}
@@ -212,13 +212,13 @@ final class LibraryPreviewNode {
212212

213213
for (final unit in units) {
214214
final LibraryFragment fragment = unit.libraryFragment;
215-
for (final LibraryImport importedLib in fragment.libraryImports2) {
216-
if (importedLib.importedLibrary2 == null) {
215+
for (final LibraryImport importedLib in fragment.libraryImports) {
216+
if (importedLib.importedLibrary == null) {
217217
// This is an import for a file that's not analyzed (likely an import of a package from
218218
// the pub-cache) and isn't necessary to track as part of the dependency graph.
219219
continue;
220220
}
221-
final LibraryElement2 importedLibrary = importedLib.importedLibrary2!;
221+
final LibraryElement importedLibrary = importedLib.importedLibrary!;
222222
final LibraryPreviewNode result = graph.putIfAbsent(
223223
importedLibrary.toPreviewPath(),
224224
() => LibraryPreviewNode(library: importedLibrary, logger: logger),

packages/flutter_tools/lib/src/widget_preview/preview_code_generator.dart

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import 'package:analyzer/dart/constant/value.dart';
66
import 'package:analyzer/dart/element/element2.dart' as analyzer;
77
import 'package:analyzer/dart/element/element2.dart';
88
import 'package:analyzer/dart/element/type.dart';
9-
// ignore: implementation_imports, can be removed when package:analyzer 8.1.0 is released.
10-
import 'package:analyzer/src/dart/constant/value.dart';
119
import 'package:built_collection/built_collection.dart';
1210
import 'package:code_builder/code_builder.dart' as cb;
1311
import 'package:dart_style/dart_style.dart';
@@ -254,45 +252,44 @@ class PreviewCodeGenerator {
254252

255253
extension on DartObject {
256254
cb.Expression toExpression() {
257-
final objectImpl = this as DartObjectImpl;
258255
final DartType type = this.type!;
259256
return switch (type) {
260257
DartType(isDartCoreBool: true) => cb.literalBool(toBoolValue()!),
261258
DartType(isDartCoreDouble: true) => cb.literalNum(toDoubleValue()!),
262259
DartType(isDartCoreInt: true) => cb.literalNum(toIntValue()!),
263260
DartType(isDartCoreString: true) => cb.literalString(toStringValue()!),
264261
DartType(isDartCoreNull: true) => cb.literalNull,
265-
InterfaceType(element3: EnumElement2()) => _createEnumInstance(objectImpl),
266-
InterfaceType() => _createInstance(type, objectImpl),
267-
FunctionType() => _createTearoff(toFunctionValue2()!),
262+
InterfaceType(element3: EnumElement()) => _createEnumInstance(this),
263+
InterfaceType() => _createInstance(type, this),
264+
FunctionType() => _createTearoff(toFunctionValue()!),
268265
_ => throw UnsupportedError('Unexpected DartObject type: $runtimeType'),
269266
};
270267
}
271268

272-
cb.Expression _createTearoff(ExecutableElement2 element) {
269+
cb.Expression _createTearoff(ExecutableElement element) {
273270
return cb.refer(element.displayName, _elementToLibraryIdentifier(element));
274271
}
275272

276-
cb.Expression _createEnumInstance(DartObjectImpl object) {
277-
final VariableElement2 variable = object.variable2!;
273+
cb.Expression _createEnumInstance(DartObject object) {
274+
final VariableElement variable = object.variable!;
278275
return switch (variable) {
279-
FieldElement2(
276+
FieldElement(
280277
isEnumConstant: true,
281278
displayName: final enumValue,
282-
enclosingElement2: EnumElement2(displayName: final enumName),
279+
enclosingElement: EnumElement(displayName: final enumName),
283280
) =>
284281
cb.refer('$enumName.$enumValue', _elementToLibraryIdentifier(variable)),
285-
PropertyInducingElement2(:final displayName) => cb.refer(
282+
PropertyInducingElement(:final displayName) => cb.refer(
286283
displayName,
287284
_elementToLibraryIdentifier(variable),
288285
),
289286
_ => throw UnsupportedError('Unexpected enum variable type: ${variable.runtimeType}'),
290287
};
291288
}
292289

293-
cb.Expression _createInstance(InterfaceType dartType, DartObjectImpl object) {
294-
final ConstructorInvocation constructorInvocation = object.getInvocation()!;
295-
final ConstructorElement2 constructor = constructorInvocation.constructor2;
290+
cb.Expression _createInstance(InterfaceType dartType, DartObject object) {
291+
final ConstructorInvocation constructorInvocation = object.constructorInvocation!;
292+
final ConstructorElement constructor = constructorInvocation.constructor;
296293
final cb.Expression type = cb.refer(
297294
dartType.element3.name3!,
298295
_elementToLibraryIdentifier(dartType.element3),
@@ -317,6 +314,6 @@ extension on DartObject {
317314
);
318315
}
319316

320-
/// Returns the import URI for the [analyzer.LibraryElement2] containing [element].
321-
String? _elementToLibraryIdentifier(analyzer.Element2? element) => element?.library2!.identifier;
317+
/// Returns the import URI for the [analyzer.LibraryElement] containing [element].
318+
String? _elementToLibraryIdentifier(analyzer.Element? element) => element?.library!.identifier;
322319
}

packages/flutter_tools/lib/src/widget_preview/preview_detector.dart

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,20 @@ class PreviewDetector {
191191
final unit =
192192
(await context.currentSession.getResolvedUnit(filePath)) as ResolvedUnitResult;
193193
lib = await context.currentSession.getResolvedLibrary(
194-
unit.libraryElement2.firstFragment.source.fullName,
194+
unit.libraryElement.firstFragment.source.fullName,
195195
);
196196
}
197197
if (lib is ResolvedLibraryResult) {
198198
final ResolvedLibraryResult resolvedLib = lib;
199-
final PreviewPath previewPath = lib.element2.toPreviewPath();
199+
final PreviewPath previewPath = lib.element.toPreviewPath();
200200
// This library has already been processed.
201201
if (updatedPreviews.containsKey(previewPath)) {
202202
continue;
203203
}
204204

205205
final LibraryPreviewNode previewsForLibrary = _dependencyGraph.putIfAbsent(
206206
previewPath,
207-
() => LibraryPreviewNode(library: resolvedLib.element2, logger: logger),
207+
() => LibraryPreviewNode(library: resolvedLib.element, logger: logger),
208208
);
209209

210210
previewsForLibrary.updateDependencyGraph(graph: _dependencyGraph, units: lib.units);

packages/flutter_tools/lib/src/widget_preview/utils.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,22 +32,22 @@ extension AnnotationExtension on Annotation {
3232
/// Convenience getter to identify `@Preview` annotations
3333
bool get isPreview =>
3434
name.name == 'Preview' &&
35-
elementAnnotation!.element2?.library2!.uri == widgetPreviewsLibraryUri;
35+
elementAnnotation!.element?.library!.uri == widgetPreviewsLibraryUri;
3636

3737
bool get isMultiPreview {
38-
final Element2? element = elementAnnotation!.element2;
39-
if (element is ConstructorElement2) {
40-
final InterfaceType type = element.enclosingElement2.supertype!;
38+
final Element? element = elementAnnotation!.element;
39+
if (element is ConstructorElement) {
40+
final InterfaceType type = element.enclosingElement.supertype!;
4141
return type.getDisplayString() == 'MultiPreview' &&
42-
type.element3.library2.uri == widgetPreviewsLibraryUri;
42+
type.element.library.uri == widgetPreviewsLibraryUri;
4343
}
4444
return false;
4545
}
4646

4747
List<DartObject> findMultiPreviewPreviewNodes({required AnalysisContext context}) {
4848
final DartObject evaluatedAnnotation = elementAnnotation!.computeConstantValue()!;
49-
final Element2 element = evaluatedAnnotation.type!.element3!;
50-
if (element is ClassElement2) {
49+
final Element element = evaluatedAnnotation.type!.element!;
50+
if (element is ClassElement) {
5151
final InterfaceType type = element.supertype!;
5252
if (type.getDisplayString() != 'MultiPreview') {
5353
throw StateError('$element is not a MultiPreview!');
@@ -67,7 +67,7 @@ extension StringExtension on String {
6767
bool get doesContainDartTool => contains('.dart_tool');
6868
}
6969

70-
extension LibraryElement2Extension on LibraryElement2 {
70+
extension LibraryElementExtension on LibraryElement {
7171
/// Convenience method to package path and [uri] into a [PreviewPath]
7272
PreviewPath toPreviewPath() => (path: firstFragment.source.fullName, uri: uri);
7373
}

packages/flutter_tools/pubspec.yaml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencies:
1010
#
1111
# For detailed instructions, refer to:
1212
# https://github.com/flutter/flutter/blob/main/docs/infra/Updating-dependencies-in-Flutter.md
13+
analyzer: 8.1.1
1314
archive: 3.6.1
1415
args: 2.7.0
1516
dds: 5.0.3
@@ -23,13 +24,13 @@ dependencies:
2324
file: 7.0.1
2425
flutter_template_images: 5.0.0
2526
html: 0.15.6
26-
http: 1.4.0
27+
http: 1.5.0
2728
intl: 0.20.2
2829
meta: 1.17.0
2930
multicast_dns: 0.3.3
3031
mustache_template: 2.0.0
3132
package_config: 2.2.0
32-
process: 5.0.4
33+
process: 5.0.5
3334
fake_async: 1.3.3
3435
stack_trace: 1.12.1
3536
usage: 4.1.1
@@ -71,20 +72,19 @@ dependencies:
7172

7273
standard_message_codec: 0.0.1+4
7374

74-
dart_style: 3.1.0
75+
dart_style: 3.1.2
7576

7677
# The below dependencies are transitive and are here to pin them to a specific version.
77-
_fe_analyzer_shared: 82.0.0
78-
analyzer: 7.4.5
78+
_fe_analyzer_shared: 88.0.0
7979
boolean_selector: 2.1.2
8080
browser_launcher: 1.1.3
8181
built_collection: 5.1.1
82-
built_value: 8.11.0
82+
built_value: 8.11.1
8383
cli_config: 0.2.0
8484
clock: 1.1.2
8585
csslib: 1.0.2
8686
dap: 1.4.0
87-
dds_service_extensions: 2.0.2
87+
dds_service_extensions: 2.1.0
8888
devtools_shared: 12.0.0
8989
dtd: 4.0.0
9090
extension_discovery: 2.1.0
@@ -126,4 +126,4 @@ dev_dependencies:
126126
dartdoc:
127127
# Exclude this package from the hosted API docs.
128128
nodoc: true
129-
# PUBSPEC CHECKSUM: 932agm
129+
# PUBSPEC CHECKSUM: f0tepf

packages/flutter_tools/test/widget_preview_scaffold.shard/widget_preview_scaffold/pubspec.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ dependencies:
1414
# These will be replaced with proper constraints after the template is hydrated.
1515
dtd: 2.5.1
1616
flutter_lints: 6.0.0
17-
google_fonts: 6.2.1
17+
google_fonts: 6.3.0
1818
stack_trace: 1.12.1
1919
url_launcher: 6.3.2
2020

@@ -27,7 +27,7 @@ dependencies:
2727
crypto: 3.0.6
2828
fake_async: 1.3.3
2929
file: 7.0.1
30-
http: 1.4.0
30+
http: 1.5.0
3131
http_parser: 4.1.2
3232
json_rpc_2: 3.0.3
3333
leak_tracker: 11.0.1
@@ -46,7 +46,7 @@ dependencies:
4646
test_api: 0.7.7
4747
typed_data: 1.4.0
4848
unified_analytics: 8.0.1
49-
url_launcher_android: 6.3.16
49+
url_launcher_android: 6.3.17
5050
url_launcher_ios: 6.3.3
5151
url_launcher_linux: 3.2.1
5252
url_launcher_macos: 3.2.2
@@ -62,4 +62,4 @@ dependencies:
6262
flutter:
6363
uses-material-design: true
6464

65-
# PUBSPEC CHECKSUM: patulg
65+
# PUBSPEC CHECKSUM: b279i4

0 commit comments

Comments
 (0)