Skip to content

Commit fc57872

Browse files
committed
Update documentation snapshot
1 parent d7791b5 commit fc57872

29 files changed

+1353
-372
lines changed

docs/api-guide.html

Lines changed: 536 additions & 55 deletions
Large diffs are not rendered by default.

docs/checks/AnnotateVersionCheck.md.html

Lines changed: 12 additions & 166 deletions
Original file line numberDiff line numberDiff line change
@@ -41,215 +41,61 @@
4141

4242
Here is an example of lint warnings produced by this check:
4343
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~text
44-
src/test/pkg/Utils.kt:12:Warning: This method should be annotated with
44+
src/test/pkg/test.kt:8:Warning: This method should be annotated with
4545
@ChecksSdkIntAtLeast(api=VERSION_CODES.N) [AnnotateVersionCheck]
4646

47-
fun isNougat1(): Boolean = VERSION.SDK_INT >= VERSION_CODES.N // 1: Should be annotated
48-
---------
49-
50-
51-
src/test/pkg/Utils.kt:14:Warning: This method should be annotated with
52-
@ChecksSdkIntAtLeast(api=VERSION_CODES.N) [AnnotateVersionCheck]
53-
54-
fun isNougat2(): Boolean { // 2: Should be annotated
55-
---------
56-
57-
58-
src/test/pkg/Utils.kt:18:Warning: This method should be annotated with
59-
@ChecksSdkIntAtLeast(parameter=0) [AnnotateVersionCheck]
60-
61-
fun isAtLeast2(api: Int): Boolean { // 3: Should be annotated
62-
----------
47+
fun isNougat(): Boolean {
48+
--------
6349

6450

65-
src/test/pkg/Utils.kt:22:Warning: This method should be annotated with
51+
src/test/pkg/test.kt:12:Warning: This method should be annotated with
6652
@ChecksSdkIntAtLeast(parameter=0) [AnnotateVersionCheck]
6753

68-
fun isAtLeast2g(api: Int): Boolean = VERSION.SDK_INT >= api // 4: Should be annotated
69-
-----------
70-
71-
72-
src/test/pkg/Utils.kt:25:Warning: This method should be annotated with
73-
@ChecksSdkIntAtLeast(api=Build.VERSION_CODES.ICE_CREAM_SANDWICH)
74-
[AnnotateVersionCheck]
75-
76-
val isIcs: Boolean // 5: Should be annotated
77-
-----
78-
79-
80-
src/test/pkg/Utils.kt:27:Warning: This method should be annotated with
81-
@ChecksSdkIntAtLeast(api=Build.VERSION_CODES.GINGERBREAD)
82-
[AnnotateVersionCheck]
83-
84-
val isGingerbread: Boolean // 6: Should be annotated
85-
-------------
54+
fun isAtLeast(api: Int): Boolean {
55+
---------
8656

8757

88-
src/test/pkg/Utils.kt:31:Warning: This method should be annotated with
58+
src/test/pkg/test.kt:16:Warning: This method should be annotated with
8959
@ChecksSdkIntAtLeast(api=Build.VERSION_CODES.O, lambda=1)
9060
[AnnotateVersionCheck]
9161

92-
inline fun <T> T.applyForOreoOrAbove(block: T.() -> Unit): T { // 7: Should be annotated
62+
inline fun <T> T.applyForOreoOrAbove(block: T.() -> Unit): T {
9363
-------------------
9464

9565

96-
src/test/pkg/Utils.kt:38:Warning: This method should be annotated with
97-
@ChecksSdkIntAtLeast(api=Build.VERSION_CODES.O, lambda=1)
98-
[AnnotateVersionCheck]
99-
100-
inline fun <T> T.applyForOreoOrAbove2(block: T.() -> Unit): Unit { // 8: Should be annotated
101-
--------------------
102-
103-
104-
src/test/pkg/Utils.kt:46:Warning: This method should be annotated with
105-
@ChecksSdkIntAtLeast(parameter=0, lambda=1) [AnnotateVersionCheck]
106-
107-
inline fun <T> sdk(level: Int, func: () -> T): T? { // 9: Should be annotated
108-
---
109-
110-
111-
src/test/pkg/Utils.kt:54:Warning: This method should be annotated with
112-
@ChecksSdkIntAtLeast(parameter=0, lambda=1) [AnnotateVersionCheck]
113-
114-
inline fun <T> sdk2(level: Int, func: () -> T): T? = // 10: Should be annotated
115-
----
116-
117-
118-
src/test/pkg/Utils.kt:61:Warning: This method should be annotated with
119-
@ChecksSdkIntAtLeast(parameter=0, lambda=1) [AnnotateVersionCheck]
120-
121-
inline fun fromApi(value: Int, action: () -> Unit) { // 11: Should be annotated
122-
-------
123-
124-
125-
src/test/pkg/Utils.kt:67:Warning: This method should be annotated with
126-
@ChecksSdkIntAtLeast(parameter=0, lambda=1) [AnnotateVersionCheck]
127-
128-
fun fromApiNonInline(value: Int, action: () -> Unit) { // 12: Should be annotated
129-
----------------
130-
131-
132-
src/test/pkg/Utils.kt:79:Warning: This method should be annotated with
133-
@ChecksSdkIntAtLeast(api=android.os.Build.VERSION_CODES.N_MR1)
134-
[AnnotateVersionCheck]
135-
136-
fun isAfterNougat(): Boolean { // 14: Should be annotated
137-
-------------
138-
139-
14066
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
14167

14268
Here is the source file referenced above:
14369

144-
`src/test/pkg/Utils.kt`:
70+
`src/test/pkg/test.kt`:
14571
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers
146-
@file:Suppress("unused", "RemoveRedundantQualifierName")
147-
14872
package test.pkg
14973

15074
import android.os.Build
15175
import android.os.Build.VERSION
15276
import android.os.Build.VERSION.SDK_INT
15377
import android.os.Build.VERSION_CODES
154-
import androidx.annotation.ChecksSdkIntAtLeast
155-
import androidx.core.os.BuildCompat
156-
157-
fun isNougat1(): Boolean = VERSION.SDK_INT >= VERSION_CODES.N // 1: Should be annotated
15878

159-
fun isNougat2(): Boolean { // 2: Should be annotated
79+
fun isNougat(): Boolean {
16080
return VERSION.SDK_INT >= VERSION_CODES.N
16181
}
16282

163-
fun isAtLeast2(api: Int): Boolean { // 3: Should be annotated
83+
fun isAtLeast(api: Int): Boolean {
16484
return VERSION.SDK_INT >= api
16585
}
16686

167-
fun isAtLeast2g(api: Int): Boolean = VERSION.SDK_INT >= api // 4: Should be annotated
168-
169-
private object Utils {
170-
val isIcs: Boolean // 5: Should be annotated
171-
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH
172-
val isGingerbread: Boolean // 6: Should be annotated
173-
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD
174-
}
175-
176-
inline fun <T> T.applyForOreoOrAbove(block: T.() -> Unit): T { // 7: Should be annotated
87+
inline fun <T> T.applyForOreoOrAbove(block: T.() -> Unit): T {
17788
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
17889
block()
17990
}
18091
return this
18192
}
182-
183-
inline fun <T> T.applyForOreoOrAbove2(block: T.() -> Unit): Unit { // 8: Should be annotated
184-
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
185-
block()
186-
} else {
187-
error("Unexpected")
188-
}
189-
}
190-
191-
inline fun <T> sdk(level: Int, func: () -> T): T? { // 9: Should be annotated
192-
return if (Build.VERSION.SDK_INT >= level) {
193-
func()
194-
} else {
195-
null
196-
}
197-
}
198-
199-
inline fun <T> sdk2(level: Int, func: () -> T): T? = // 10: Should be annotated
200-
if (Build.VERSION.SDK_INT >= level) {
201-
func()
202-
} else {
203-
null
204-
}
205-
206-
inline fun fromApi(value: Int, action: () -> Unit) { // 11: Should be annotated
207-
if (Build.VERSION.SDK_INT >= value) {
208-
action()
209-
}
210-
}
211-
212-
fun fromApiNonInline(value: Int, action: () -> Unit) { // 12: Should be annotated
213-
if (Build.VERSION.SDK_INT >= value) {
214-
action()
215-
}
216-
}
217-
218-
inline fun notFromApi(value: Int, action: () -> Unit) { // 13: Suggest in the future?
219-
if (Build.VERSION.SDK_INT < value) {
220-
action()
221-
}
222-
}
223-
224-
fun isAfterNougat(): Boolean { // 14: Should be annotated
225-
return VERSION.SDK_INT > VERSION_CODES.N
226-
}
227-
228-
@ChecksSdkIntAtLeast(api = Build.VERSION_CODES.N)
229-
fun isNougat3(): Boolean { // Should NOT annotate (already annotated)
230-
return VERSION.SDK_INT >= VERSION_CODES.N
231-
}
232-
233-
private var unrelated: Boolean = false
234-
fun unrelated(): Boolean {
235-
unrelated = SDK_INT > VERSION_CODES.N; return false; } // Should NOT annotate
236-
237-
fun isAtLeastN(): Boolean { // 15: Could annotate in the future
238-
return BuildCompat.isAtLeastN()
239-
}
240-
241-
fun isAtLeastN2(): Boolean = BuildCompat.isAtLeastN() // 16: Could annotate in the future
24293
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
24394

24495
You can also visit the
24596
[source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-master-dev:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/SdkIntDetectorTest.kt)
24697
for the unit tests for this check to see additional scenarios.
24798

248-
The above example was automatically extracted from the first unit test
249-
found for this lint check, `SdkIntDetector.testChecksSdkIntAtLeast`.
250-
To report a problem with this extracted sample, visit
251-
https://issuetracker.google.com/issues/new?component=192708.
252-
25399
(##) Suppressing
254100

255101
You can suppress false positives using one of the following mechanisms:

docs/checks/CoarseFineLocation.md.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,6 @@
6565
[source code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-master-dev:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/FineLocationDetectorTest.kt)
6666
for the unit tests for this check to see additional scenarios.
6767

68-
The above example was automatically extracted from the first unit test
69-
found for this lint check, `FineLocationDetector.testFineNoCoarsePermissionPostS`.
70-
To report a problem with this extracted sample, visit
71-
https://issuetracker.google.com/issues/new?component=192708.
72-
7368
(##) Suppressing
7469

7570
You can suppress false positives using one of the following mechanisms:

0 commit comments

Comments
 (0)