Skip to content

Commit 8714d26

Browse files
committed
Update lint documentation snapshot.
1 parent 149982f commit 8714d26

14 files changed

+105
-105
lines changed

docs/api-guide/annotations.md.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
The second case shows a similar situation where the array syntax will
107107
end up calling our extension method, `get()`.
108108

109-
And the third case shows the most common scenario: a straight forward
109+
And the third case shows the most common scenario: a straightforward
110110
method call to an annotated method.
111111

112112
In many cases, the above detector implementation is nearly all you have
@@ -322,7 +322,7 @@
322322

323323
The `fileStack.push` call on line 4 also resolves to the same method
324324
as the call on line 2 (even though the concrete type is a `FileStack`
325-
instead of a `Stack), so like on line 2, this call is taken to be
325+
instead of a `Stack`), so like on line 2, this call is taken to be
326326
thread safe.
327327

328328
However, the `fileStack.pop` call on line 6 resolves to the API method

docs/api-guide/basics.md.html

+31-33
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,13 @@
169169

170170
Many detector methods will pass in a `Context`, or a more specific
171171
subclass of `Context` such as `JavaContext` or `XmlContext`. This
172-
allows lint to provide access to the detectors information they may
173-
need, without passing in a lot of parameters (and allowing lint to add
174-
additional data over time without breaking signatures).
172+
allows lint to give the detectors information they may need, without
173+
passing in a lot of parameters. It also allows lint to add additional data
174+
over time without breaking signatures.
175175

176176
The `Context` classes also provide many convenience APIs. For example,
177177
for `XmlContext` there are methods for creating locations for XML tags,
178-
XML attributes, just the name part of an XML attribute and just the
178+
XML attributes, just the name part of an XML attribute, and just the
179179
value part of an XML attribute. For a `JavaContext` there are also
180180
methods for creating locations, such as for a method call, including
181181
whether to include the receiver and/or the argument list.
@@ -204,7 +204,7 @@
204204
Lint's API has two halves:
205205

206206
- The **Client API**: “Integrate (and run) lint from within a tool”.
207-
For example, both the IDE and the build system uses this API to embed
207+
For example, both the IDE and the build system use this API to embed
208208
and invoke lint to analyze the code in the project or editor.
209209

210210
- The **Detector API**: “Implement a new lint check”. This is the API
@@ -213,27 +213,26 @@
213213
The class in the Client API which represents lint running in a tool is
214214
called `LintClient`. This class is responsible for, among other things:
215215

216-
* Reporting incidents found by detectors. For example, in the IDE, it
216+
* **Reporting incidents found by detectors**. For example, in the IDE, it
217217
will place error markers into the source editor, and in a build
218218
system, it may write warnings to the console or generate a report or
219219
even fail the build.
220220

221-
* Handling I/O. Detectors should never read files from disk directly.
221+
* **Handling I/O**. Detectors should never read files from disk directly.
222222
This allows lint checks to work smoothly in for example the IDE. When
223223
lint runs on the fly, and a lint check asks for the source file
224224
contents (or other supporting files), the `LintClient` in the IDE
225225
will implement the `readFile` method to first look in the open source
226226
editors and if the requested file is being edited, it will return the
227227
current (often unsaved!) contents.
228228

229-
* Handling network traffic. Lint checks should never open
230-
URLConnections themselves. By going through the lint API to request
231-
data for a URL, not only can the LintClient for example use any
232-
configured IDE proxy settings which is done in the IntelliJ
233-
integration of lint, but even the lint check's own unit tests can
234-
easily be tested because the special unit test implementation of a
235-
`LintClient` provides a simple way to provide exact responses for
236-
specific URLs:
229+
* **Handling network traffic**. Lint checks should never open
230+
URLConnections themselves. Instead, they should go through the lint API
231+
to request data for URLs. Among other things, this allows the
232+
`LintClient` to use configured IDE proxy settings (as is done in the
233+
IntelliJ integration of lint). This is also good for testing, because
234+
the special unit test implementation of a `LintClient` has a simple way
235+
to provide exact responses for specific URLs:
237236

238237
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
239238
lint()
@@ -256,8 +255,8 @@
256255

257256
And much, much, more. **However, most of the implementation of
258257
`LintClient` is intended for integration of lint itself, and as a check
259-
author you don't need to worry about it.** It's the detector API that
260-
matters, and is also less likely to change than the client API.
258+
author you don't need to worry about it.** The detector API will matter
259+
more, and it's also less likely to change than the client API.
261260

262261
!!! Tip
263262
The division between the two halves is not perfect; some classes
@@ -273,8 +272,8 @@
273272
for internal lint usage have been made `public` such that lint's
274273
code in one package can access it from the other. There's normally a
275274
comment explaining that this is for internal use only, but be aware
276-
that just because something is `public` or not `final` it's a good
277-
idea to call or override it.
275+
that even when something is `public` or not `final`, it might not be a
276+
good idea to call or override it.
278277

279278
## Creating an Issue
280279

@@ -283,7 +282,7 @@
283282
[publishing](publishing.md.html) chapters.
284283

285284
`Issue` is a final class, so unlike `Detector`, you don't subclass
286-
it, you instantiate it via `Issue.create`.
285+
it; you instantiate it via `Issue.create`.
287286

288287
By convention, issues are registered inside the companion object of the
289288
corresponding detector, but that is not required.
@@ -631,16 +630,16 @@
631630

632631
* When implementing **`SourceCodeScanner`**, in Kotlin and Java files
633632
you can be called back
634-
- When a method of a given name is invoked (`getApplicableMethodNames`
633+
- when a method of a given name is invoked (`getApplicableMethodNames`
635634
and `visitMethodCall`)
636-
- When a class of the given type is instantiated
635+
- when a class of the given type is instantiated
637636
(`getApplicableConstructorTypes` and `visitConstructor`)
638-
- When a new class is declared which extends (possibly indirectly)
637+
- when a new class is declared which extends (possibly indirectly)
639638
a given class or interface (`applicableSuperClasses` and
640639
`visitClass`)
641-
- When annotated elements are referenced or combined
640+
- when annotated elements are referenced or combined
642641
(`applicableAnnotations` and `visitAnnotationUsage`)
643-
- When any AST nodes of given types appear (`getApplicableUastTypes`
642+
- when any AST nodes of given types appear (`getApplicableUastTypes`
644643
and `createUastHandler`)
645644

646645
* When implementing a **`ClassScanner`**, in `.class` and `.jar` files
@@ -650,7 +649,7 @@
650649
- when a given bytecode instruction occurs
651650
(`getApplicableAsmNodeTypes` and `checkInstruction`)
652651
- like with XmlScanner's `visitDocument`, you can perform your own
653-
ASM bytecode iteration via `checkClass`.
652+
ASM bytecode iteration via `checkClass`
654653

655654
* There are various other scanners too, for example `GradleScanner`
656655
which lets you visit `build.gradle` and `build.gradle.kts` DSL
@@ -677,9 +676,9 @@
677676
the detector in fields and accumulate information for analysis at the
678677
end.
679678

680-
There are some callbacks both before each individual file is analyzed
681-
(`beforeCheckFile` and `afterCheckFile`), as well as before and after
682-
analysis of all the modules (`beforeCheckRootProject` and
679+
There are some callbacks both before and after each individual file is
680+
analyzed (`beforeCheckFile` and `afterCheckFile`), as well as before and
681+
after analysis of all the modules (`beforeCheckRootProject` and
683682
`afterCheckRootProject`).
684683

685684
This is for example how the ”unused resources“ check works: we store
@@ -764,8 +763,7 @@
764763
like the `ResourceRepository` and the `ResourceEvaluator`.
765764

766765
* Finally, there are a number of utility methods; for example there is
767-
an `editDistance` method used to find likely typos used by a number
768-
of checks.
766+
an `editDistance` method used to find likely typos.
769767

770768
## Scanner Example
771769

@@ -807,7 +805,7 @@
807805
}
808806
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
809807

810-
The second, older form, may seem simpler, but the new API allows a lot
808+
The second (older) form may seem simpler, but the new API allows a lot
811809
more metadata to be attached to the report, such as an override
812810
severity. You don't have to convert to the builder syntax to do this;
813811
you could also have written the second form as
@@ -1003,7 +1001,7 @@
10031001

10041002
!!! Warning
10051003
Resolving only works if lint has a correct classpath such that the
1006-
referenced method, field or class are actually present. If it is
1004+
referenced method, field, or class is actually present. If it is
10071005
not, resolve will return null, and various lint callbacks will not
10081006
be invoked. This is a common source of questions for lint checks
10091007
”not working“; it frequently comes up in lint unit tests where a

docs/api-guide/dataflow-analyzer.md.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
}
8484
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8585

86-
Aas you can see, the `DataFlowAnalyzer` is a visitor, so when we find a
86+
As you can see, the `DataFlowAnalyzer` is a visitor, so when we find a
8787
call we're interested in, we construct a `DataFlowAnalyzer` and
8888
initialize it with the instance we want to track, and then we visit the
8989
surrounding method with this visitor.
@@ -254,8 +254,8 @@
254254
call.
255255

256256
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin linenumbers
257-
fun test) {
258-
val transaction = getFragmentManager().beginTransaction()
257+
fun test() {
258+
val transaction = getFragmentManager().beginTransaction()
259259
process(transaction)
260260
}
261261
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

docs/api-guide/faq.md.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -110,14 +110,14 @@
110110

111111
### How do I get the `UMethod` for a `PsiMethod` ?
112112

113-
Call `psiMethod.toUElementOfType<UMethod>()`. Note that this may return
113+
Call `psiMethod.toUElementOfType&lt;UMethod>()`. Note that this may return
114114
null if UAST cannot find valid Java or Kotlin source code for the
115115
method.
116116

117117
For `PsiField` and `PsiClass` instances use the equivalent
118118
`toUElementOfType` type arguments.
119119

120-
### How do get a `JavaEvaluator` ?
120+
### How do get a `JavaEvaluator`?
121121

122122
The `Context` passed into most of the `Detector` callback methods
123123
relevant to Kotlin and Java analysis is of type `JavaContext`, and it
@@ -173,7 +173,7 @@
173173
abstract fun getTypeClass(psiType: PsiType?): PsiClass?
174174
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
175175

176-
### How do I look up hierarhcy annotations for an element?
176+
### How do I look up hierarchy annotations for an element?
177177

178178
You can directly look up annotations via the modified list
179179
of PsiElement or the annotations for a `UAnnotated` element,
@@ -254,7 +254,7 @@
254254
open fun computeArgumentMapping(
255255
call: UCallExpression,
256256
method: PsiMethod
257-
): Map<UExpression, PsiParameter> { /* ... */
257+
): Map&lt;UExpression, PsiParameter> { /* ... */
258258
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
259259

260260
This returns a map from UAST expressions (each argument to a UAST call
@@ -290,7 +290,7 @@
290290
### Why are overloaded operators not handled?
291291

292292
Kotlin supports overloaded operators, but these are not handled as
293-
calls in the AST - instead, an implicit `get` or `set` method from an
293+
calls in the AST -- instead, an implicit `get` or `set` method from an
294294
array access will show up as a `UArrayAccessExpression`. Lint has
295295
specific support to help handling these scenarios; see the “Implicit
296296
Calls” section in the [basics chapter](basics.md.html).

docs/api-guide/messages.md.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
## Punctuation
4343

44-
One line error messages should not be punctuated - e.g. the error message
44+
One line error messages should not be punctuated -- e.g. the error message
4545
should be “Unused import foo”, not “Unused import foo.”
4646

4747
However, if there are multiple sentences in the error message, all sentences

docs/api-guide/partial-analysis.md.html

+4-4
Original file line numberDiff line numberDiff line change
@@ -308,8 +308,8 @@
308308
represents it. To report an incident you simply call
309309
`context.report(incident)`. There are several ways to create these
310310
incidents. The easiest is to simply edit your existing call above by
311-
adding `Incident(` (or from Java, `new Incident(`) inside the
312-
`context.report` block like this:
311+
putting it inside `Incident(...)` (in Java, `new Incident(...)`) inside
312+
the `context.report` block like this:
313313

314314
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin
315315
context.report(Incident(
@@ -390,7 +390,7 @@
390390
from the `Constraints` class.
391391

392392
Recording an incident with a constraint is easy; first construct the
393-
`Incident` as before, and then report them via
393+
`Incident` as before, and then report it via
394394
`context.report(incident, constraint)`:
395395

396396
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~java
@@ -403,7 +403,7 @@
403403
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
404404

405405
Finally, note that you can combine constraints; there are both “and”
406-
and “or” operators defined for the `Constraint` class. so the following
406+
and “or” operators defined for the `Constraint` class, so the following
407407
is valid:
408408

409409
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~kotlin

docs/api-guide/publishing.md.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@
126126
* and is no longer registered, any existing mentions of the issue
127127
* id in baselines, lint.xml files etc are gracefully handled.
128128
*/
129-
open val deletedIssues: List<String> = emptyList()
129+
open val deletedIssues: List&lt;String> = emptyList()
130130
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
131131

132132
The reason you'll want to do this is listed right there in the doc: If
@@ -136,7 +136,7 @@
136136
is done to catch issue id typos. And if the user has a baseline file
137137
listing incidents from your check, then if your issue id is not
138138
registered as deleted, lint will think this is an issue that has been
139-
"fixed“ since it's no longer reported, and lint will issue an
139+
“fixed” since it's no longer reported, and lint will issue an
140140
informational message that the baseline contains issues no longer
141141
reported (which is done such that users can update their baseline
142142
files, to ensure that the fixed issues aren't reintroduced again.)

docs/api-guide/terminology.md.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010
Configuration
1111
: A configuration provides extra information or parameters to lint on a
12-
per project, or even per directory basis. For example, the `lint.xml`
12+
per-project, or even per-directory, basis. For example, the `lint.xml`
1313
files can change the severity for issues, or list incidents to ignore
1414
(matched for example by a regular expression), or even provide values
1515
for options read by a specific detector.
1616

1717
Context
1818
: An object passed into detectors in many APIs, providing data about
1919
(for example) which file is being analyzed (and in which project),
20-
and for specific types of analysis additional information; for
20+
and (for specific types of analysis) additional information; for
2121
example, an XmlContext points to the DOM document, a JavaContext
2222
includes the AST, and so on.
2323

@@ -97,7 +97,7 @@
9797
Java and Kotlin files, there is a scope for .class files, and so on.
9898

9999
Typically lint cares about which **set** of scopes apply,
100-
so most of the APIs take an `EnumSet< Scope>`, but we'll often
100+
so most of the APIs take an `EnumSet&lt;Scope>`, but we'll often
101101
refer to this as just “the scope” instead of the “scope set”.
102102

103103
Severity

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
There are a number of built-in test modes:
1111

12-
* Test modes which makes small tweaks to the source files which
12+
* Test modes which make small tweaks to the source files which
1313
should be compatible, such as
1414
* Inserting unnecessary parentheses
1515
* Replacing imported symbols with fully qualified names
@@ -36,7 +36,7 @@
3636
`skipTestModes` DSL method, as described below.
3737

3838
You can also add in your own test modes. For example, lint adds its own
39-
internal test mode for making sure the built-in annotation checks works
39+
internal test mode for making sure the built-in annotation checks work
4040
with Android platform annotations in the following test mode:
4141

4242
[](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/AndroidPlatformAnnotationsTestMode.kt)
@@ -322,7 +322,7 @@
322322
last argument is a literal expression such as a number or a String. You
323323
*can't* just use `if (call.valueArguments.lastOrNull() is
324324
ULiteralExpression)`, because that first argument could be a
325-
`UParenthesizedExpression`, as in `call(1, true, ("hello")), so you'd
325+
`UParenthesizedExpression`, as in `call(1, true, ("hello"))`, so you'd
326326
need to look inside the parentheses.
327327

328328
UAST comes with two functions to help you handle this correctly:

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

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
## Trimming indents?
175175

176176
Notice how in the above Kotlin unit tests we used raw strings, **and**
177-
we indented the sources to be flush with the opening “”“ string
177+
we indented the sources to be flush with the opening `"""` string
178178
delimiter.
179179

180180
You might be tempted to call `.trimIndent()` on the raw string.
@@ -412,7 +412,7 @@
412412
"BwAAAAIAAQAIAAkAAQAKAAAAHQABAAEAAAAFKrcAAbEAAAABAAsAAAAGAAEA" +
413413
"AAAEAAgADAAJAAEACgAAAB4AAQAAAAAABhICswADsQAAAAEACwAAAAYAAQAA" +
414414
"AAUAAQANAAAAAgAO"
415-
)`
415+
)
416416
).run().expect(
417417
```
418418

@@ -450,7 +450,7 @@
450450
and emit the full test file registration.
451451

452452
This isn't just a convenience; lint's test infrastructure also uses
453-
this to test some additional scenarios (for example, in a multi- module
453+
this to test some additional scenarios (for example, in a multi-module
454454
project it will only provide the binaries, not the sources, for
455455
upstream modules.)
456456

0 commit comments

Comments
 (0)