Commit ae68d36
Kotlin: read KDoc sections via Kotlin PSI, not com.intellij.psi navigation
The previous two commits removed the `ProcessCanceledException` and
`PsiTreeUtil` references from KDoc-section parsing, but the internal extractor
build then failed on `unresolved reference 'PsiElement'`: the hand-written tree
walk named `com.intellij.psi.PsiElement` (and its `firstChild`/`nextSibling`).
The root cause is that the LighterAST/K2 comment extractor is compiled against a
curated classpath that deliberately excludes `com.intellij.psi.*`. It exposes
only the `com.intellij.lang` LighterAST API (`LighterASTNode`,
`FlyweightCapableTreeStructure`) plus the Kotlin PSI classes
(`org.jetbrains.kotlin.psi.*`, `...kdoc.psi.*`). That is why `KtPsiFactory`,
`KtFile`, `KDoc` and `getAllSections` all resolve while any `com.intellij.psi`
reference does not. The full standalone builds bundle the whole classpath, so
they never caught this.
Locate the parsed KDoc through the Kotlin PSI API instead: the KDoc attaches to
the throwaway `val __codeql_kdoc__` as its `docComment`, so
`ktFile.declarations.firstOrNull()?.docComment` retrieves it using only
`org.jetbrains.kotlin.psi` types (`KtCommonFile.getDeclarations`,
`KtDeclaration.getDocComment`). No `com.intellij.psi` symbol remains in the
file's code. Behaviour is unchanged: the parsed input is a single KDoc comment
followed by one declaration, so its `docComment` is exactly the KDoc the old
descendant search returned.
No expected-output changes. Verified the standalone extractor builds for
1.9.0-Beta and 2.4.0.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 0abbd89 commit ae68d36
1 file changed
Lines changed: 9 additions & 23 deletions
File tree
- java/kotlin-extractor/src/main/kotlin/utils/versions/v_1_9_0-Beta
Lines changed: 9 additions & 23 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | 55 | | |
77 | 56 | | |
78 | 57 | | |
79 | 58 | | |
80 | 59 | | |
81 | 60 | | |
82 | | - | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
83 | 69 | | |
84 | | - | |
| 70 | + | |
85 | 71 | | |
86 | 72 | | |
87 | 73 | | |
| |||
0 commit comments