aboutsummaryrefslogtreecommitdiff
path: root/src/Model/DocumentationModel.kt
diff options
context:
space:
mode:
authorIlya Ryzhenkov <orangy@jetbrains.com>2014-07-12 01:12:42 +0400
committerIlya Ryzhenkov <orangy@jetbrains.com>2014-07-12 01:12:42 +0400
commit046265ea04b645b4f8ff835aa6c3ff9879501aed (patch)
tree27856cad58e73c95978c16e264beed806047b9e7 /src/Model/DocumentationModel.kt
parent2f4e56d77ac72c3f47cd2799094b1b987b0d9522 (diff)
downloaddokka-046265ea04b645b4f8ff835aa6c3ff9879501aed.tar.gz
dokka-046265ea04b645b4f8ff835aa6c3ff9879501aed.tar.bz2
dokka-046265ea04b645b4f8ff835aa6c3ff9879501aed.zip
Add Owner references, cleanup
Diffstat (limited to 'src/Model/DocumentationModel.kt')
-rw-r--r--src/Model/DocumentationModel.kt26
1 files changed, 21 insertions, 5 deletions
diff --git a/src/Model/DocumentationModel.kt b/src/Model/DocumentationModel.kt
index 77bd8373..06bc3775 100644
--- a/src/Model/DocumentationModel.kt
+++ b/src/Model/DocumentationModel.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka
+import org.jetbrains.jet.lang.resolve.scopes.JetScope
import org.jetbrains.jet.lang.resolve.BindingContext
import org.jetbrains.jet.lang.psi.JetFile
@@ -9,9 +10,11 @@ public enum class DocumentationNodeKind {
Package
Class
Object
+
Constructor
Function
Property
+
Parameter
Receiver
TypeParameter
@@ -19,19 +22,21 @@ public enum class DocumentationNodeKind {
LowerBound
Exception
- Page
Model
}
public enum class DocumentationReferenceKind {
+ Owner
Member
Detail
- Owner
Link
Override
}
-public open class DocumentationNode(val name: String, val doc: String, val kind: DocumentationNodeKind) {
+public open class DocumentationNode(val name: String,
+ val doc: String,
+ val kind: DocumentationNodeKind,
+ val scope: JetScope) {
private val references = arrayListOf<DocumentationReference>()
public val owner: DocumentationNode
@@ -54,12 +59,12 @@ public open class DocumentationNode(val name: String, val doc: String, val kind:
public fun references(kind: DocumentationReferenceKind): List<DocumentationReference> = references.filter { it.kind == kind }
- public override fun toString() : String {
+ public override fun toString(): String {
return "$kind $name"
}
}
-public class DocumentationModel : DocumentationNode("model", "", DocumentationNodeKind.Model) {
+public class DocumentationModel : DocumentationNode("model", "", DocumentationNodeKind.Model, JetScope.EMPTY) {
fun merge(other: DocumentationModel): DocumentationModel {
val model = DocumentationModel()
model.addAllReferencesFrom(other)
@@ -72,3 +77,14 @@ public class DocumentationModel : DocumentationNode("model", "", DocumentationNo
}
public data class DocumentationReference(val from: DocumentationNode, val to: DocumentationNode, val kind: DocumentationReferenceKind)
+
+fun BindingContext.createDocumentationModel(file: JetFile): DocumentationModel {
+ val model = DocumentationModel()
+ val packageFragment = getPackageFragment(file)
+ if (packageFragment == null) throw IllegalArgumentException("File $file should have package fragment")
+
+ val visitor = DocumentationNodeBuilder(this)
+ packageFragment.accept(DocumentationBuildingVisitor(this, visitor), model)
+
+ return model
+}