This repository was archived by the owner on Jul 16, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +24
-3
lines changed
lint_analyzer/rules/rules_list
test/resources/unused_files_analyzer Expand file tree Collapse file tree 6 files changed +24
-3
lines changed Original file line number Diff line number Diff line change 11# Changelog
22
3+ ## Unreleased
4+
5+ * Improve unused files check, add support for ` vm:entry-point ` annotation.
6+
37## 4.3.1
48
59* Update .pubignore
Original file line number Diff line number Diff line change @@ -55,7 +55,7 @@ class _Visitor extends RecursiveAstVisitor<void> {
5555
5656 Iterable <FormalParameter > _getUnusedParameters (
5757 Iterable <SyntacticEntity > children,
58- NodeList <FormalParameter > parameters,
58+ Iterable <FormalParameter > parameters,
5959 ) {
6060 final result = < FormalParameter > [];
6161
Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ class _Visitor extends RecursiveAstVisitor<void> {
3030 _visitArguments (node.argumentList.arguments);
3131 }
3232
33- void _visitArguments (NodeList <Expression > arguments) {
33+ void _visitArguments (Iterable <Expression > arguments) {
3434 final notIgnoredArguments = arguments.where (_isNotIgnored).toList ();
3535
3636 for (final argument in notIgnoredArguments) {
Original file line number Diff line number Diff line change @@ -35,8 +35,22 @@ class UnusedFilesVisitor extends GeneralizingAstVisitor<void> {
3535
3636 @override
3737 void visitFunctionDeclaration (FunctionDeclaration node) {
38- if (node.name.name == 'main' ) {
38+ if (node.name.name == 'main' || _hasPragmaAnnotation (node.metadata) ) {
3939 _paths.add (_currentFilePath);
4040 }
4141 }
42+
43+ /// See https://github.com/dart-lang/sdk/blob/master/runtime/docs/compiler/aot/entry_point_pragma.md
44+ bool _hasPragmaAnnotation (Iterable <Annotation > metadata) =>
45+ metadata.where ((annotation) {
46+ final arguments = annotation.arguments;
47+
48+ return annotation.name.name == 'pragma' &&
49+ arguments != null &&
50+ arguments.arguments
51+ .where ((argument) =>
52+ argument is SimpleStringLiteral &&
53+ argument.stringValue == 'vm:entry-point' )
54+ .isNotEmpty;
55+ }).isNotEmpty;
4256}
Original file line number Diff line number Diff line change 1+ @pragma ('vm:entry-point' )
2+ void customEntryPoint () {}
Original file line number Diff line number Diff line change 11import 'exported_file.dart' ;
22
3+ @immutable
34class SomeClass {}
45
56const instance = ExportedClass ();
You can’t perform that action at this time.
0 commit comments