Skip to content

Commit 19b49b5

Browse files
authored
Merge pull request googlesamples#74 from googlesamples/snapshot11
Update documentation snapshot
2 parents 3466f52 + 2de21d6 commit 19b49b5

File tree

81 files changed

+3875
-491
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3875
-491
lines changed

docs/README.md.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5353

5454
Documentation History:
55+
* May 2022: Noticed that the document rendering
56+
was broken, such that many chapters were missing from
57+
the api-guide: "Adding Quickfixes", "Partial Analysis",
58+
"Data Flow Analyzer", "Annotations", and "Options".
59+
These are now included.
5560
* November 2021: Added documentation for [option
5661
handling](api-guide/options.md.html)
5762
* September 2021: Added documentation for [annotation

docs/api-guide.html

Lines changed: 484 additions & 70 deletions
Large diffs are not rendered by default.

docs/api-guide/annotations.md.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,18 @@
120120
isn't ignored, e.g. that it's stored into a variable or passed into
121121
another method call.
122122

123+
!!! Tip
124+
In `applicableAnnotations`, you typically return the fully
125+
qualified names of the annotation classes your detector is
126+
targeting. However, in some cases, it's useful to match all
127+
annotations of a given name; for example, there are many, many
128+
variations of the `@Nullable` annotations, and you don't really
129+
want to be in the business of keeping track of and listing all of
130+
them here. Lint will also let you specify just the basename of an
131+
annotation here, such as `"Nullable"`, and if so, annotations like
132+
`androidx.annotation.Nullable` and
133+
`org.jetbrains.annotations.Nullable` will both match.
134+
123135
## Annotation Usage Types and isApplicableAnnotationUsage
124136

125137
### Method Override

docs/api-guide/basics.md.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@
342342
src/main/kotlin/test/pkg/MyTest.kt:4: Warning: Do not hardcode "/sdcard/";
343343
use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]
344344
val s: String = "/sdcard/mydir"
345-
~~~~~~~~~~~~~
345+
-------------
346346
0 errors, 1 warnings
347347
```
348348

docs/api-guide/changes.md.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,18 @@
55
information about user visible changes to lint, see the User
66
Guide.
77

8+
**7.4**
9+
10+
* Annotation detectors can now specify just an annotation name instead
11+
of its fully qualified name in order to match *all* annotations of
12+
that name. For example,
13+
`override fun applicableAnnotations() = listOf("Nullable")`
14+
will match both `androidx.annotation.Nullable` and
15+
`org.jetbrains.annotations.Nullable`. This is used by for example
16+
the built-in CheckResultDetector to match many new variants of the
17+
`CheckReturnValue` annotations, such as the ones in mockito and in
18+
protobuf.
19+
820
**7.3**
921

1022
* The new AnnotationUsageType.DEFINTION now lets detectors easily check

docs/api-guide/options.md.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@
169169
```text
170170
lint.xml:4: Error: duration: Must be less than 15.0 [LintError]
171171
<option name="duration" value="100.0" />
172-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
172+
----------------------------------------
173173
1 errors, 0 warnings
174174
```
175175

docs/api-guide/test-modes.md.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,9 @@
196196
instead:
197197

198198
```
199-
src/test/pkg/ExifUsage.java:9: Warning: Avoid using android.media.ExifInterface; use androidx.media.ExifInterface instead [ExifInterface]
199+
src/test/pkg/ExifUsage.java:9: Warning: Avoid using android.media.ExifInterface; use androidx.exifinterface.media.ExifInterface instead [ExifInterface]
200200
android.media.ExifInterface exif = new android.media.ExifInterface(path);
201-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
201+
---------------------------
202202
```
203203

204204
However, if you explicitly (via fully qualified imports) reference the

docs/api-guide/unit-testing.md.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@
322322
app/src/com/example/MyDiffUtilCallbackJava.java:4: Error:
323323
Couldn't resolve this import [LintError]
324324
import androidx.recyclerview.widget.DiffUtil;
325-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325+
-------------------------------------
326326

327327
This usually means that the unit test needs to declare a stub file or
328328
placeholder with the expected signature such that type resolving works.
@@ -334,9 +334,6 @@
334334
(This check only enforces import references, not all references, so if
335335
it doesn't matter to the detector, you can just remove the import but
336336
leave references to the class in the code.)
337-
338-
For more information, see the "Library Dependencies and Stubs" section in
339-
https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/docs/api-guide/unit-testing.md.html
340337
```
341338

342339
## Binary and Compiled Source Files

docs/checks/AppCompatMethod.md.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
: `AppCompatMethod`
99
Summary
1010
: Using Wrong AppCompat Method
11+
Note
12+
: **This issue is disabled by default**; use `--enable AppCompatMethod`
1113
Severity
1214
: Warning
1315
Category
@@ -125,7 +127,7 @@
125127
for the unit tests for this check to see additional scenarios.
126128

127129
The above example was automatically extracted from the first unit test
128-
found for this lint check, `AppCompatCallDetector.testArguments`.
130+
found for this lint check, `AppCompatCallDetector.testArgumentsSupportV4`.
129131
To report a problem with this extracted sample, visit
130132
https://issuetracker.google.com/issues/new?component=192708.
131133

docs/checks/CoroutineCreationDuringComposition.md.html

Lines changed: 78 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,118 +44,174 @@
4444

4545
Here is an example of lint warnings produced by this check:
4646
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
47-
src/androidx/compose/runtime/foo/test.kt:9:Error: Calls to async should
47+
src/androidx/compose/runtime/foo/test.kt:10:Error: Calls to async should
4848
happen inside a LaunchedEffect and not composition
4949
[CoroutineCreationDuringComposition]
5050

5151
CoroutineScope.async {}
5252
-----
5353

5454

55-
src/androidx/compose/runtime/foo/test.kt:10:Error: Calls to launch
55+
src/androidx/compose/runtime/foo/test.kt:11:Error: Calls to launch
5656
should happen inside a LaunchedEffect and not composition
5757
[CoroutineCreationDuringComposition]
5858

5959
CoroutineScope.launch {}
6060
------
6161

6262

63-
src/androidx/compose/runtime/foo/test.kt:14:Error: Calls to async should
63+
src/androidx/compose/runtime/foo/test.kt:12:Error: Calls to launchIn
64+
should happen inside a LaunchedEffect and not composition
65+
[CoroutineCreationDuringComposition]
66+
67+
flowOf(Unit).launchIn(CoroutineScope)
68+
--------
69+
70+
71+
src/androidx/compose/runtime/foo/test.kt:16:Error: Calls to async should
6472
happen inside a LaunchedEffect and not composition
6573
[CoroutineCreationDuringComposition]
6674

6775
CoroutineScope.async {}
6876
-----
6977

7078

71-
src/androidx/compose/runtime/foo/test.kt:15:Error: Calls to launch
79+
src/androidx/compose/runtime/foo/test.kt:17:Error: Calls to launch
7280
should happen inside a LaunchedEffect and not composition
7381
[CoroutineCreationDuringComposition]
7482

7583
CoroutineScope.launch {}
7684
------
7785

7886

79-
src/androidx/compose/runtime/foo/test.kt:19:Error: Calls to async should
87+
src/androidx/compose/runtime/foo/test.kt:18:Error: Calls to launchIn
88+
should happen inside a LaunchedEffect and not composition
89+
[CoroutineCreationDuringComposition]
90+
91+
flowOf(Unit).launchIn(CoroutineScope)
92+
--------
93+
94+
95+
src/androidx/compose/runtime/foo/test.kt:22:Error: Calls to async should
8096
happen inside a LaunchedEffect and not composition
8197
[CoroutineCreationDuringComposition]
8298

8399
CoroutineScope.async {}
84100
-----
85101

86102

87-
src/androidx/compose/runtime/foo/test.kt:20:Error: Calls to launch
103+
src/androidx/compose/runtime/foo/test.kt:23:Error: Calls to launch
88104
should happen inside a LaunchedEffect and not composition
89105
[CoroutineCreationDuringComposition]
90106

91107
CoroutineScope.launch {}
92108
------
93109

94110

95-
src/androidx/compose/runtime/foo/test.kt:29:Error: Calls to async should
111+
src/androidx/compose/runtime/foo/test.kt:24:Error: Calls to launchIn
112+
should happen inside a LaunchedEffect and not composition
113+
[CoroutineCreationDuringComposition]
114+
115+
flowOf(Unit).launchIn(CoroutineScope)
116+
--------
117+
118+
119+
src/androidx/compose/runtime/foo/test.kt:33:Error: Calls to async should
96120
happen inside a LaunchedEffect and not composition
97121
[CoroutineCreationDuringComposition]
98122

99123
CoroutineScope.async {}
100124
-----
101125

102126

103-
src/androidx/compose/runtime/foo/test.kt:30:Error: Calls to launch
127+
src/androidx/compose/runtime/foo/test.kt:34:Error: Calls to launch
104128
should happen inside a LaunchedEffect and not composition
105129
[CoroutineCreationDuringComposition]
106130

107131
CoroutineScope.launch {}
108132
------
109133

110134

111-
src/androidx/compose/runtime/foo/test.kt:33:Error: Calls to async should
135+
src/androidx/compose/runtime/foo/test.kt:35:Error: Calls to launchIn
136+
should happen inside a LaunchedEffect and not composition
137+
[CoroutineCreationDuringComposition]
138+
139+
flowOf(Unit).launchIn(CoroutineScope)
140+
--------
141+
142+
143+
src/androidx/compose/runtime/foo/test.kt:38:Error: Calls to async should
112144
happen inside a LaunchedEffect and not composition
113145
[CoroutineCreationDuringComposition]
114146

115147
CoroutineScope.async {}
116148
-----
117149

118150

119-
src/androidx/compose/runtime/foo/test.kt:34:Error: Calls to launch
151+
src/androidx/compose/runtime/foo/test.kt:39:Error: Calls to launch
120152
should happen inside a LaunchedEffect and not composition
121153
[CoroutineCreationDuringComposition]
122154

123155
CoroutineScope.launch {}
124156
------
125157

126158

127-
src/androidx/compose/runtime/foo/test.kt:40:Error: Calls to async should
159+
src/androidx/compose/runtime/foo/test.kt:40:Error: Calls to launchIn
160+
should happen inside a LaunchedEffect and not composition
161+
[CoroutineCreationDuringComposition]
162+
163+
flowOf(Unit).launchIn(CoroutineScope)
164+
--------
165+
166+
167+
src/androidx/compose/runtime/foo/test.kt:46:Error: Calls to async should
128168
happen inside a LaunchedEffect and not composition
129169
[CoroutineCreationDuringComposition]
130170

131171
CoroutineScope.async {}
132172
-----
133173

134174

135-
src/androidx/compose/runtime/foo/test.kt:41:Error: Calls to launch
175+
src/androidx/compose/runtime/foo/test.kt:47:Error: Calls to launch
136176
should happen inside a LaunchedEffect and not composition
137177
[CoroutineCreationDuringComposition]
138178

139179
CoroutineScope.launch {}
140180
------
141181

142182

143-
src/androidx/compose/runtime/foo/test.kt:45:Error: Calls to async should
183+
src/androidx/compose/runtime/foo/test.kt:48:Error: Calls to launchIn
184+
should happen inside a LaunchedEffect and not composition
185+
[CoroutineCreationDuringComposition]
186+
187+
flowOf(Unit).launchIn(CoroutineScope)
188+
--------
189+
190+
191+
src/androidx/compose/runtime/foo/test.kt:52:Error: Calls to async should
144192
happen inside a LaunchedEffect and not composition
145193
[CoroutineCreationDuringComposition]
146194

147195
CoroutineScope.async {}
148196
-----
149197

150198

151-
src/androidx/compose/runtime/foo/test.kt:46:Error: Calls to launch
199+
src/androidx/compose/runtime/foo/test.kt:53:Error: Calls to launch
152200
should happen inside a LaunchedEffect and not composition
153201
[CoroutineCreationDuringComposition]
154202

155203
CoroutineScope.launch {}
156204
------
157205

158206

207+
src/androidx/compose/runtime/foo/test.kt:54:Error: Calls to launchIn
208+
should happen inside a LaunchedEffect and not composition
209+
[CoroutineCreationDuringComposition]
210+
211+
flowOf(Unit).launchIn(CoroutineScope)
212+
--------
213+
214+
159215
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
160216

161217
Here is the source file referenced above:
@@ -166,21 +222,25 @@
166222

167223
import androidx.compose.runtime.Composable
168224
import kotlinx.coroutines.*
225+
import kotlinx.coroutines.flow.*
169226

170227
@Composable
171228
fun Test() {
172229
CoroutineScope.async {}
173230
CoroutineScope.launch {}
231+
flowOf(Unit).launchIn(CoroutineScope)
174232
}
175233

176234
val lambda = @Composable {
177235
CoroutineScope.async {}
178236
CoroutineScope.launch {}
237+
flowOf(Unit).launchIn(CoroutineScope)
179238
}
180239

181240
val lambda2: @Composable () -> Unit = {
182241
CoroutineScope.async {}
183242
CoroutineScope.launch {}
243+
flowOf(Unit).launchIn(CoroutineScope)
184244
}
185245

186246
@Composable
@@ -191,22 +251,26 @@
191251
LambdaParameter(content = {
192252
CoroutineScope.async {}
193253
CoroutineScope.launch {}
254+
flowOf(Unit).launchIn(CoroutineScope)
194255
})
195256
LambdaParameter {
196257
CoroutineScope.async {}
197258
CoroutineScope.launch {}
259+
flowOf(Unit).launchIn(CoroutineScope)
198260
}
199261
}
200262

201263
fun test3() {
202264
val localLambda1 = @Composable {
203265
CoroutineScope.async {}
204266
CoroutineScope.launch {}
267+
flowOf(Unit).launchIn(CoroutineScope)
205268
}
206269

207270
val localLambda2: @Composable () -> Unit = {
208271
CoroutineScope.async {}
209272
CoroutineScope.launch {}
273+
flowOf(Unit).launchIn(CoroutineScope)
210274
}
211275
}
212276
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

0 commit comments

Comments
 (0)