This repository was archived by the owner on Jul 16, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +16
-11
lines changed
lib/src/analyzers/unused_l10n_analyzer
test/resources/unused_l10n_analyzer Expand file tree Collapse file tree 5 files changed +16
-11
lines changed Original file line number Diff line number Diff line change 1313* feat: facelift console reporters.
1414* chore: restrict ` analyzer ` version to ` >=2.4.0 <3.1.0 ` .
1515* chore: restrict ` analyzer_plugin ` version to ` >=0.8.0 <0.10.0 ` .
16- * feat: support extensions for check-unused-l10n.
16+ * feat: support extensions and static getters for check-unused-l10n.
1717* feat: improve ` prefer-correct-type-name ` rule.
1818* build: activate check_unused_files on CI.
1919
Original file line number Diff line number Diff line change @@ -76,12 +76,8 @@ class UnusedL10nVisitor extends RecursiveAstVisitor<void> {
7676 final classTarget = (target as PrefixedIdentifier ).identifier;
7777
7878 _addMemberInvocationOnAccessor (classTarget, name);
79- } else if (_matchMethodOf (target)) {
80- final classTarget = (target as MethodInvocation ).target;
81-
82- if (_matchIdentifier (classTarget)) {
83- _addMemberInvocation (classTarget as SimpleIdentifier , name);
84- }
79+ } else if (_matchStaticGetter (target)) {
80+ _addMemberInvocation ((target as PrefixedIdentifier ).prefix, name);
8581 }
8682 }
8783
@@ -102,6 +98,12 @@ class UnusedL10nVisitor extends RecursiveAstVisitor<void> {
10298 target is PrefixedIdentifier &&
10399 target.staticElement? .enclosingElement is ExtensionElement ;
104100
101+ bool _matchStaticGetter (Expression ? target) =>
102+ target is PrefixedIdentifier &&
103+ _classPattern.hasMatch (
104+ target.staticType? .getDisplayString (withNullability: false ) ?? '' ,
105+ );
106+
105107 void _addMemberInvocation (SimpleIdentifier target, String name) {
106108 final staticElement = target.staticElement;
107109
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ class S {
4141
4242 return S ();
4343 }
44+
45+ // ignore: prefer_constructors_over_static_methods
46+ static S get current => S ();
4447}
4548
4649class L10nClass {
Original file line number Diff line number Diff line change @@ -23,6 +23,6 @@ class SomeClass {
2323
2424 void method () {
2525 S .of ('' ).regularMethod ('' );
26- S .of ( '' ) .regularGetter;
26+ S .current .regularGetter;
2727 }
2828}
Original file line number Diff line number Diff line change @@ -11,9 +11,6 @@ module.exports = {
1111 projectName : 'dart-code-metrics' ,
1212 trailingSlash : false ,
1313 themeConfig : {
14- gtag : {
15- trackingID : 'G-C2B16RHS34' ,
16- } ,
1714 algolia : {
1815 apiKey : '77b6353dcfcae7da42fcb75524a90002' ,
1916 indexName : 'dartcodemetrics' ,
@@ -146,6 +143,9 @@ module.exports = {
146143 theme : {
147144 customCss : require . resolve ( './src/css/custom.css' ) ,
148145 } ,
146+ gtag : {
147+ trackingID : 'G-C2B16RHS34' ,
148+ } ,
149149 } ,
150150 ] ,
151151 ] ,
You can’t perform that action at this time.
0 commit comments