Skip to content

Commit

Permalink
Elements. Migrate tool/benchmark/heap/flutter_elements.dart
Browse files Browse the repository at this point in the history
Change-Id: Ie60dbfbba92d9717fb4fb0e3709be2a24f1aa39a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/395084
Reviewed-by: Phil Quitslund <[email protected]>
Commit-Queue: Konstantin Shcheglov <[email protected]>
Reviewed-by: Brian Wilkerson <[email protected]>
  • Loading branch information
scheglov authored and Commit Queue committed Nov 13, 2024
1 parent 6907727 commit 1747e2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
1 change: 0 additions & 1 deletion pkg/analyzer/analyzer_use_new_elements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,4 +331,3 @@ test/util/element_printer.dart
test/util/element_type_matchers.dart
test/util/id_testing_helper.dart
test/utils.dart
tool/benchmark/heap/flutter_elements.dart
14 changes: 8 additions & 6 deletions pkg/analyzer/tool/benchmark/heap/flutter_elements.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import 'dart:io' as io;
import 'dart:typed_data';

import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/visitor.dart';
import 'package:analyzer/dart/element/element2.dart';
import 'package:analyzer/dart/element/visitor2.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
Expand Down Expand Up @@ -268,7 +268,7 @@ Future<void> _getAvailableLibraries(
// }
var result = await analysisDriver.getLibraryByUri(file.uriStr);
if (result is LibraryElementResult) {
result.element.accept(_AllElementVisitor());
result.element2.accept2(_AllElementVisitor());
}
}
}
Expand Down Expand Up @@ -331,11 +331,13 @@ void _writeResultFile(BenchmarkResultCompound result) {
io.File(_resultFilePath).writeAsStringSync(result.asXmlText, flush: true);
}

class _AllElementVisitor extends GeneralizingElementVisitor<void> {
class _AllElementVisitor extends GeneralizingElementVisitor2<void> {
@override
void visitElement(Element element) {
void visitElement(Element2 element) {
// This triggers lazy reading.
element.metadata;
if (element case Annotatable element) {
element.metadata2;
}
super.visitElement(element);
}
}
Expand Down

0 comments on commit 1747e2d

Please sign in to comment.