blob: b5b6b1a21267bc783638869cb65c6d11070dffd7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
package org.jetbrains.dokka
import org.jetbrains.jet.lang.resolve.name.*
import org.jetbrains.jet.lang.descriptors.*
fun DocumentationNode.checkResolve() {
val parentScope = scope
for (item in details + members) {
val symbolName = item.name
val symbol: DeclarationDescriptor? = when (item.kind) {
DocumentationNodeKind.Receiver -> (parentScope.getContainingDeclaration() as FunctionDescriptor).getReceiverParameter()
DocumentationNodeKind.Parameter -> parentScope.getLocalVariable(Name.guess(symbolName))
DocumentationNodeKind.Function -> parentScope.getFunctions(Name.guess(symbolName)).firstOrNull()
DocumentationNodeKind.Property -> parentScope.getProperties(Name.guess(symbolName)).firstOrNull()
DocumentationNodeKind.Constructor -> parentScope.getFunctions(Name.guess(symbolName)).firstOrNull()
DocumentationNodeKind.Package -> {
// TODO: do not resolve constructors and packages for now
item.scope.getContainingDeclaration()
}
else -> parentScope.getClassifier(Name.guess(symbolName))
}
if (symbol == null)
println("WARNING: Cannot resolve $item in ${path(this)}")
}
for (reference in allReferences().filterNot { it.kind == DocumentationReferenceKind.Owner }) {
reference.to.checkResolve()
}
}
fun path(node: DocumentationNode) : String {
val owner = node.owner
if (owner != null)
return "$node in ${path(owner)}"
else
return "$node"
}
|