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 13
13
* feat: facelift console reporters.
14
14
* chore: restrict ` analyzer ` version to ` >=2.4.0 <3.1.0 ` .
15
15
* 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.
17
17
* feat: improve ` prefer-correct-type-name ` rule.
18
18
* build: activate check_unused_files on CI.
19
19
Original file line number Diff line number Diff line change @@ -76,12 +76,8 @@ class UnusedL10nVisitor extends RecursiveAstVisitor<void> {
76
76
final classTarget = (target as PrefixedIdentifier ).identifier;
77
77
78
78
_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);
85
81
}
86
82
}
87
83
@@ -102,6 +98,12 @@ class UnusedL10nVisitor extends RecursiveAstVisitor<void> {
102
98
target is PrefixedIdentifier &&
103
99
target.staticElement? .enclosingElement is ExtensionElement ;
104
100
101
+ bool _matchStaticGetter (Expression ? target) =>
102
+ target is PrefixedIdentifier &&
103
+ _classPattern.hasMatch (
104
+ target.staticType? .getDisplayString (withNullability: false ) ?? '' ,
105
+ );
106
+
105
107
void _addMemberInvocation (SimpleIdentifier target, String name) {
106
108
final staticElement = target.staticElement;
107
109
Original file line number Diff line number Diff line change @@ -41,6 +41,9 @@ class S {
41
41
42
42
return S ();
43
43
}
44
+
45
+ // ignore: prefer_constructors_over_static_methods
46
+ static S get current => S ();
44
47
}
45
48
46
49
class L10nClass {
Original file line number Diff line number Diff line change @@ -23,6 +23,6 @@ class SomeClass {
23
23
24
24
void method () {
25
25
S .of ('' ).regularMethod ('' );
26
- S .of ( '' ) .regularGetter;
26
+ S .current .regularGetter;
27
27
}
28
28
}
Original file line number Diff line number Diff line change @@ -11,9 +11,6 @@ module.exports = {
11
11
projectName : 'dart-code-metrics' ,
12
12
trailingSlash : false ,
13
13
themeConfig : {
14
- gtag : {
15
- trackingID : 'G-C2B16RHS34' ,
16
- } ,
17
14
algolia : {
18
15
apiKey : '77b6353dcfcae7da42fcb75524a90002' ,
19
16
indexName : 'dartcodemetrics' ,
@@ -146,6 +143,9 @@ module.exports = {
146
143
theme : {
147
144
customCss : require . resolve ( './src/css/custom.css' ) ,
148
145
} ,
146
+ gtag : {
147
+ trackingID : 'G-C2B16RHS34' ,
148
+ } ,
149
149
} ,
150
150
] ,
151
151
] ,
You can’t perform that action at this time.
0 commit comments