Skip to content

Commit daea968

Browse files
committed
Proofread the documentation
1 parent b58a343 commit daea968

23 files changed

+158
-157
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ You might want to check the [generated documentation website](https://kotl.in/an
88

99
---
1010

11-
Analysis API is a powerful library for analyzing code in Kotlin.
11+
The Analysis API is a powerful library for analyzing code in Kotlin.
1212
Made on top of the Kotlin PSI syntax tree, it provides access to various semantic information, including reference targets,
1313
expression types, declaration scopes, diagnostics, and more.

Writerside/topics/Annotations.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Annotations
22

3-
Annotations play a crucial role in Kotlin, providing metadata and influencing code behavior. Analysis API allows you
4-
to access and analyze annotations applied to both declarations and types.
3+
Annotations play a crucial role in Kotlin, providing metadata and influencing code behavior.
4+
The Analysis API allows you to access and analyze annotations applied to both declarations and types.
55

66
## KaAnnotated
77

Writerside/topics/Diagnostics.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Diagnostics
22

3-
Analysis API allows you to access and analyze compiler diagnostics (errors and warnings) associated with entire files
4-
or specific elements.
3+
The Analysis API allows you to access and analyze compiler diagnostics (errors and warnings) associated with entire
4+
files or specific elements.
55

66
## Diagnostics in a `KtFile`
77

@@ -41,8 +41,6 @@ Note that the returned list of diagnostics does not include diagnostics for nest
4141
`collectDiagnostics` and `diagnostics` return a collection of `KtDiagnosticWithPsi` instances.
4242
This interface provides access to information about the diagnostic.
4343

44-
45-
4644
| Member | Description |
4745
|------------------|-------------------------------------------------------------------------------|
4846
| `severity` | The severity of the diagnostic (e.g., `ERROR`, `WARNING`). |

Writerside/topics/File-Compilation.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<note>Experimental API. Subject to changes.</note>
44

5-
Analysis API enables in-memory compilation of Kotlin files. This allows your tools and plugins to generate and compile
6-
Kotlin code without writing files to disk or invoking the command-line compiler.
5+
The Analysis API enables in-memory compilation of Kotlin files. This allows your tools and plugins to generate and
6+
compile Kotlin code without writing files to disk or invoking the command-line compiler.
77

88
## Usage
99

Writerside/topics/Fundamentals.md

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ This page covers a few fundamental concepts and rules of the Analysis API. Pleas
44

55
## Kotlin PSI
66

7-
The Kotlin compiler exposes a Kotlin abstract syntax tree, made on top of the
8-
[PSI](https://plugins.jetbrains.com/docs/intellij/psi.html) API, a part of IntelliJ IDEA. For some languages, such as
9-
Java, the PSI acts both as a syntax tree, and as a source of semantic information. In Kotlin, though, these concepts
7+
The Kotlin compiler exposes a Kotlin abstract syntax tree, built on top of
8+
the [PSI](https://plugins.jetbrains.com/docs/intellij/psi.html) API, a part of IntelliJ IDEA. For some languages, such
9+
as Java, the PSI acts both as a syntax tree and as a source of semantic information. In Kotlin, though, these concepts
1010
are clearly separated.
1111

12-
Below there is a simplified tree of the Kotlin PSI hierarchy.
12+
Below is a simplified tree of the Kotlin PSI hierarchy.
1313

1414
<code-block lang="mermaid">
1515
graph TD
@@ -28,24 +28,25 @@ graph TD
2828
KtExpression --> KtBlockExpression
2929
</code-block>
3030

31-
`KtElement` is a root type of the hierarchy. `KtDeclaration` and `KtExpression` are two notable subtypes of it.
32-
`KtDeclaration` itself is an expression – so makes it possible to have local classes and functions.
31+
`KtElement` is the root type of the hierarchy. `KtDeclaration` and `KtExpression` are two notable subtypes of
32+
it. `KtDeclaration` itself is an expression, which makes it possible to have local classes and functions.
3333

34-
The Kotlin PSI does not have a strict separation between statements and expressions. There is, however, a
35-
`KtStatementExpression` marker interface that annotates statement-like constructs.
34+
The Kotlin PSI does not have a strict separation between statements and expressions. There is, however,
35+
a `KtStatementExpression` marker interface that annotates statement-like constructs.
3636

37-
Analysis API is implemented on top of the Kotlin PSI, mostly as a set of extension functions and properties, providing
38-
access to semantic information. Such as, to get an expression type, there is a `ktExpression.expressionType` extension
39-
property. Or, to get a resolved call information, one should use `ktCallExpression.resolveToCall()`.
37+
The Analysis API is implemented on top of the Kotlin PSI, mostly as a set of extension functions and properties,
38+
providing access to semantic information. For example, to get an expression type, there is
39+
a `ktExpression.expressionType` extension property. Or, to get resolved call information, one should
40+
use `ktCallExpression.resolveToCall()`.
4041

4142
## KaSession
4243

43-
`KaSession` is the entry point for interacting with Analysis API. It provides access to various components and utilities
44-
needed for analyzing code in Kotlin.
44+
`KaSession` is the entry point for interacting with the Analysis API. It provides access to various components and
45+
utilities needed for analyzing code in Kotlin.
4546

46-
Each `KaSession` is associated with some specific module and provides analysis results from the perspective of that
47-
module. In other words, a `KaSession` only sees declarations from the owning (use-site) module, and from all
48-
dependencies of it, both direct and transitive.
47+
Each `KaSession` is associated with a specific module and provides analysis results from the perspective of that module.
48+
In other words, a `KaSession` only sees declarations from the owning (use-site) module and from all its dependencies,
49+
both direct and transitive.
4950

5051
To get a `KaSession`, use the `analyze {}` function, passing a `KtModule` or some `KtElement` from that module:
5152

@@ -61,9 +62,9 @@ fun perform(element: KtElement) {
6162
The `KaSession` is available as an extension receiver within the lambda block. The session is valid only within this
6263
block, and it **should not** be stored or accessed outside of it.
6364

64-
The `analyze {}` call is only available inside
65-
[read actions](https://plugins.jetbrains.com/docs/intellij/general-threading-rules.html#read-access). You can use the
66-
`@RequiresReadLock` annotation to specify that the method must be called from a read action. In latter parts of the
65+
The `analyze {}` call is only available
66+
inside [read actions](https://plugins.jetbrains.com/docs/intellij/general-threading-rules.html#read-access). You can use
67+
the `@RequiresReadLock` annotation to specify that the method must be called from a read action. In later parts of the
6768
documentation, the annotation is not added for clarity.
6869

6970
## KaLifetimeOwner
@@ -72,11 +73,11 @@ documentation, the annotation is not added for clarity.
7273
the `analyze` block in which they were created. All such entities have the `KaLifetimeOwner` supertype.
7374

7475
It is crucial to avoid caching `KaLifetimeOwner`s for an arbitrary time, including storing them in properties of
75-
long-living classes, or in static context. Doing so will likely lead to severe memory leaks as these entities hold the
76+
long-living classes or in a static context. Doing so will likely lead to severe memory leaks as these entities hold the
7677
whole underlying resolution session. Always retrieve and use them within the `analyze` block or pass them as parameters
7778
to functions that require them.
7879

79-
If you need to extract parts of resolution logic to a separate function, prefer passing the `KaSession` as an
80+
If you need to extract parts of the resolution logic to a separate function, prefer passing the `KaSession` as an
8081
extension or ordinary parameter, instead of keeping it in some shared context class.
8182

8283
```Kotlin
@@ -94,7 +95,7 @@ fun KaSession.check(element: KtElement) { ... }
9495
fun modify(element: KtElement) { ... }
9596
```
9697

97-
Inside the `analyze {} `block, `KaSession` is also available as a `useSiteSession` property:
98+
Inside the `analyze {}` block, `KaSession` is also available as a `useSiteSession` property:
9899

99100
```Kotlin
100101
fun perform(element: KtElement) {

Writerside/topics/Index.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Analysis API
22

3-
Analysis API is a powerful library for analyzing code in Kotlin. Made on top of the Kotlin PSI syntax tree, it provides
4-
access to various semantic information, including reference targets, expression types, declaration scopes, diagnostics
5-
and more.
3+
The Analysis API is a powerful library for analyzing code in Kotlin. Built on top of the Kotlin PSI syntax tree,
4+
it provides access to various semantic information, including reference targets, expression types, declaration scopes,
5+
diagnostics, and more.
66

7-
While Analysis API uses the Kotlin compiler internally, the API layer itself does not expose any compiler internals.
7+
While the Analysis API uses the Kotlin compiler internally, the API layer itself does not expose any compiler internals.
88
The library offers both source and binary backward compatibility for its stable parts.
99

10-
Analysis API encapsulates all challenging parts needed for efficient Kotlin code analysis, including lazy resolution and
11-
cache invalidation, so you can focus on the actual code handling logic.
10+
The Analysis API encapsulates all challenging parts needed for efficient Kotlin code analysis, including lazy resolution
11+
and cache invalidation, so you can focus on the actual code handling logic.
1212

1313
## Quick example
1414

@@ -26,7 +26,7 @@ fun KtExpression.hasStringType(): Boolean {
2626
Most of the Analysis API surface can be accessed from inside `analyze {}` blocks. Such is the `expressionType` extension
2727
property – for the given `KtExpression`, it returns the resolved type.
2828

29-
`builtinTypes` is also a part of Analysis API available inside the analysis block. It provides access to basic
29+
`builtinTypes` is also a part of the Analysis API available inside the analysis block. It provides access to basic
3030
Kotlin types, including number types, `Any`, `Nothing`, and `String`.
3131

3232
The type of `builtinTypes.string` is a `KaType`. `Ka` is a common prefix for all Analysis API components and
@@ -35,20 +35,20 @@ Check the [KaLifetimeOwner](Fundamentals.md#kalifetimeowner) section for more in
3535

3636
## Using in IntelliJ IDEA
3737

38-
Analysis API is not just some external API. It serves as the foundation for many features within the Kotlin plugin for
39-
IntelliJ IDEA, including code completion, navigation across declarations, refactorings, inspections, debugger, and
40-
many more. By using Analysis API, you get the same tools as the developers of the Kotlin plugin itself.
38+
The Analysis API is not just some external API. It serves as the foundation for many features within the Kotlin plugin
39+
for IntelliJ IDEA, including code completion, navigation across declarations, refactorings, inspections, the debugger,
40+
and many more. By using the Analysis API, you get the same tools as the developers of the Kotlin plugin itself.
4141

42-
Analysis API mainly targets the K2 Kotlin compiler, but there is also limited support for the legacy 1.0 compiler.
43-
So the same piece of logic, if implemented on top of Analysis API, can work both in the K1 and K2 Kotlin modes.
42+
The Analysis API mainly targets the K2 Kotlin compiler, but there is also limited support for the legacy 1.0 compiler.
43+
So the same piece of logic, if implemented on top of the Analysis API, can work both in the K1 and K2 Kotlin modes.
4444

4545
## Using in command-line tools
4646

47-
Analysis API can also be used in command-line tools that perform Kotlin code analysis, including linters, documentation
48-
generators, and code generating utilities.
47+
The Analysis API can also be used in command-line tools that perform Kotlin code analysis, including linters,
48+
documentation generators, and code-generating utilities.
4949

5050
<note>
5151
Currently, the only officially supported use-case is IntelliJ IDEA plugin development.
52-
While Analysis API provides the Standalone mode for command-line tool developers, it is currently in development
52+
While the Analysis API provides the Standalone mode for command-line tool developers, it is currently in development
5353
and subject to incompatible changes.
5454
</note>

Writerside/topics/Java-Kotlin-Bridging.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
<note>Experimental API. Subject to changes.</note>
44

5-
While Analysis API exposes declarations and types from the Kotlin standpoint, it works also with Java source and library
6-
declarations. The API provides a set of utilities for converting between Kotlin and Java views of declarations.
5+
While the Analysis API exposes declarations and types from the Kotlin standpoint, it works also with Java source and
6+
library declarations. The API provides a set of utilities for converting between Kotlin and Java views of declarations.
77

88
## Types
99

1010
In IntelliJ IDEA, `PsiType` is a representation for Java types. Conceptually, it is similar to [`KaType`](KaType.md).
11-
Analysis API provides mapping between the two representations.
11+
The Analysis API provides mapping between the two representations.
1212

1313
`fun PsiType.asKaType(useSitePosition: PsiElement): KaType?`
1414
: Convert the given Java type to a `KaType`.
@@ -30,7 +30,7 @@ Analysis API provides mapping between the two representations.
3030

3131
## Symbols
3232

33-
Analysis API can create symbols for Java declarations.
33+
The Analysis API can create symbols for Java declarations.
3434

3535
`val PsiClass.namedClassSymbol: KaNamedClassSymbol?`
3636
: Map a Java class to a class symbol. Always `null` for anonymous classes and type parameters (that are also

Writerside/topics/KaAnonymousObjectSymbol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# KaAnonymousObjectSymbol
22

3-
Represents anonymous object symbols, such as:
3+
Represents an anonymous object declaration, such as:
44

55
```Kotlin
66
object : Runnable {

Writerside/topics/KaCall.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# KaCall
22

33
Represents a call within Kotlin code. It encompasses various types of calls, including function calls, property
4-
accesses, and other invocations. Analysis API provides a hierarchy of `KtCall` subtypes to model different call kinds.
4+
accesses, and other invocations. The Analysis API provides a hierarchy of `KtCall` subtypes to model different call
5+
kinds.
56

67
<code-block lang="mermaid">
78
graph TB

Writerside/topics/KaCallableSymbol.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ A base class for symbols that represent callable declarations, such as functions
77
A sealed class.
88
Inherits from [KaDeclarationSymbol](KaDeclarationSymbol.md).
99

10-
Notable inheritors: [KaFunctionSymbol](KaFunctionSymbol.md), [KaVariableSymbol](KaVariableSymbol.md).
10+
Notable inheritors: [KaFunctionSymbol](KaFunctionSymbol.md), [KaVariableSymbol](KaVariableSymbol.md).
1111

1212
## Members
1313

1414
`val callableId: CallableId?`
1515
: The fully-qualified name of a declaration, or `null` if the declaration is a local one.
1616

1717
`val returnType: KaType`
18-
: The declaration's return type. For properties, a type of the property.
18+
: The declaration's return type. For properties, the type of the property.
1919

2020
`val isExtension: Boolean`
2121
: `true` if the declaration is an extension function or an extension property.
@@ -37,8 +37,8 @@ overridden declaration for `C.foo`.
3737

3838
`val KaCallableSymbol.allOverriddenSymbols: Sequence<KaCallableSymbol>`
3939
: A sequence of declarations overridden by the given declaration, both directly and indirectly.
40-
: E.g., if `A.foo` overrides `B.foo`, and `B.foo` overrides `C.foo`, both `A.foo` and `B.foo` will be returned as an
41-
overridden declaration for `C.foo`.
40+
: E.g., if `A.foo` overrides `B.foo`, and `B.foo` overrides `C.foo`, both `A.foo` and `B.foo` will be returned as
41+
overridden declarations for `C.foo`.
4242

4343
`val KaCallableSymbol.fakeOverrideOriginal: KaCallableSymbol`
4444
: The original declared symbol for a substitution or intersection override.

Writerside/topics/KaClassLikeSymbol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# KaClassLikeSymbol
22

3-
Represents a class, object, interface or a type alias declaration.
3+
Represents a class, object, interface, or a type alias declaration.
44

55
## Hierarchy
66

Writerside/topics/KaClassSymbol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# KaClassSymbol
22

3-
Represents a class, object or an interface declaration.
3+
Represents a class, object, or interface declaration.
44

55
## Use Cases
66

Writerside/topics/KaDeclarationSymbol.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# KaDeclarationSymbol
22

3-
Represents a declaration, such as a class, function or property.
3+
Represents a declaration, such as a class, function, or property.
44

55
## Hierarchy
66

@@ -12,16 +12,16 @@ Inherits from [KaSymbol](KaSymbol.md), [KaAnnotated](Annotations.md#kaannotated)
1212
: A list of applied annotations.
1313

1414
`val modality: KaSymbolModality`
15-
: Effective declaration modality (e.g., final, sealed or open).
15+
: Effective declaration modality (e.g., final, sealed, or open).
1616

1717
`val visibility: KaSymbolVisibility`
18-
: Effective declaration visibility (e.g., public, protected or private).
18+
: Effective declaration visibility (e.g., public, protected, or private).
1919

2020
`val isExpect: Boolean`
2121
: `true` if the declaration is an `expect` one.
2222

2323
`val isActual: Boolean`
24-
: `true` if the declaration is an `actual `one.
24+
: `true` if the declaration is an `actual` one.
2525

2626
`val KaDeclarationSymbol.typeParameters: List<KaTypeParameterSymbol>`
2727
: A list of type parameters for `KaTypeParameterOwnerSymbol`, an empty list otherwise.

Writerside/topics/KaEnumEntrySymbol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Represents an [enum entry](https://kotlinlang.org/docs/enum-classes.html) declar
44

55
<note>
66
In the Kotlin PSI, a <code>KtEnumEntry</code> is a <code>KtClass</code>, as it was so In the old compiler.
7-
In Analysis API, though, similarly to the K2 compiler, it is a <code>KaVariableSymbol</code>.
7+
In the Analysis API, though, similarly to the K2 compiler, it is a <code>KaVariableSymbol</code>.
88
</note>
99

1010
## Hierarchy

Writerside/topics/KaFunctionSymbol.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# KaFunctionSymbol
22

3-
Represents a function-like declaration, including named and anonymous functions, constructors and property accessors.
3+
Represents a function-like declaration, including named and anonymous functions, constructors, and property accessors.
44

55
## Hierarchy
66

Writerside/topics/KaNamedClassSymbol.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# KaNamedClassSymbol
22

3-
Represents a named class, object or an interface declaration.
3+
Represents a named class, object, or interface declaration.
44
Basically, covers all class-like declarations, excluding anonymous objects.
55

66
## Use Cases
77

8-
* **Checking for specific class features.** Use properties like `isData`, `isInner`, and `isCompanion` to
9-
determine if the class has specific characteristics.
8+
* **Checking for specific class features.** Use properties like `isData`, `isInner`, and `isCompanion` to determine if
9+
the class has specific characteristics.
1010

11-
Also see use-cases for the [KaClassSymbol](KaClassSymbol.md#use-cases) supertype.
11+
Also see use cases for the [KaClassSymbol](KaClassSymbol.md#use-cases) supertype.
1212

1313
## Hierarchy
1414

@@ -17,7 +17,7 @@ Inherits from [KaClassSymbol](KaClassSymbol.md).
1717
## Members
1818

1919
`val name: Name`
20-
: The simple declaration name, e.g. `String` for `kotlin.String`.
20+
: The simple declaration name, e.g., `String` for `kotlin.String`.
2121

2222
`val companionObject: KaNamedClassSymbol?`
2323
: The nested companion object, or `null` if there is no companion object.
@@ -27,7 +27,7 @@ Inherits from [KaClassSymbol](KaClassSymbol.md).
2727
: **Experimental API**.
2828

2929
`val isExternal: Boolean`
30-
: `true` if the declaration has the `external modifier.
30+
: `true` if the declaration has the `external` modifier.
3131

3232
`val isData: Boolean`
3333
: `true` if the declaration is a `data class`.
@@ -47,8 +47,8 @@ Inherits from [KaClassSymbol](KaClassSymbol.md).
4747
## Type utilities
4848

4949
`val KaNamedClassSymbol.defaultType: KaType`
50-
: A class type where type parameters are substituted with matching type parameter types,
51-
e.g. `List<T>` for the `List` class.
50+
: A class type where type parameters are substituted with matching type parameter types, e.g., `List<T>` for the `List`
51+
class.
5252

5353
## Relation utilities
5454

0 commit comments

Comments
 (0)