refactored the code to remove some cruft and add support for extension functions into kdoc
This commit is contained in:
@@ -31,22 +31,6 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
|
||||
|
||||
/** Base class for any compiler plugin which needs to process a KModel */
|
||||
abstract class KModelCompilerPlugin : CompilerPlugin {
|
||||
|
||||
override fun processFiles(context: BindingContext?, sources: List<JetFile?>?) {
|
||||
if (context != null && sources != null) {
|
||||
val model = KModel(context)
|
||||
model.load(sources)
|
||||
|
||||
processModel(model)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun processModel(model: KModel): Unit
|
||||
}
|
||||
|
||||
/** Generates the Kotlin Documentation for the model */
|
||||
class KDoc(val outputDir: File) : KModelCompilerPlugin() {
|
||||
|
||||
@@ -55,47 +39,3 @@ class KDoc(val outputDir: File) : KModelCompilerPlugin() {
|
||||
generator.execute()
|
||||
}
|
||||
}
|
||||
|
||||
class KDocGenerator(val model: KModel, val outputDir: File) {
|
||||
|
||||
fun execute(): Unit {
|
||||
println("Generating kdoc to $outputDir")
|
||||
run("allclasses-frame.html", AllClassesFrameTemplate(model, " target=\"classFrame\""))
|
||||
run("allclasses-noframe.html", AllClassesFrameTemplate(model))
|
||||
// run("constant-values.html", ConstantValuesTemplate(model))
|
||||
// run("deprecated-list.html", DeprecatedListTemplate(model))
|
||||
run("help-doc.html", HelpDocTemplate(model))
|
||||
// run("index-all.html", IndexAllTemplate(model))
|
||||
run("index.html", IndexTemplate(model))
|
||||
run("overview-frame.html", OverviewFrameTemplate(model))
|
||||
run("overview-summary.html", OverviewSummaryTemplate(model))
|
||||
run("overview-tree.html", OverviewTreeTemplate(model))
|
||||
run("package-list", PackageListTemplate(model))
|
||||
// run("serialized-form.html", SerializedFormTemplate(model))
|
||||
/**
|
||||
TODO
|
||||
*/
|
||||
for (p in model.packages) {
|
||||
run("${p.nameAsPath}/package-frame.html", PackageFrameTemplate(model, p))
|
||||
run("${p.nameAsPath}/package-summary.html", PackageSummaryTemplate(model, p))
|
||||
//run("${p.nameAsPath}/package-tree.html", PackageTreeTemplate(model, p))
|
||||
//run("${p.nameAsPath}/package-use.html", PackageUseTemplate(model, p))
|
||||
for (c in p.classes) {
|
||||
run("${c.nameAsPath}.html", ClassTemplate(model, p, c))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected fun run(fileName: String, template: TextTemplate): Unit {
|
||||
val file = File(outputDir, fileName)
|
||||
file.getParentFile()?.mkdirs()
|
||||
|
||||
log("Generating $fileName")
|
||||
template.renderTo(file)
|
||||
}
|
||||
|
||||
protected fun log(text: String) {
|
||||
println(text)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
package org.jetbrains.kotlin.doc
|
||||
|
||||
import std.*
|
||||
import std.util.*
|
||||
|
||||
import org.jetbrains.kotlin.doc.templates.*
|
||||
import org.jetbrains.kotlin.template.TextTemplate
|
||||
import org.jetbrains.kotlin.model.*
|
||||
|
||||
import java.io.File
|
||||
import java.util.List
|
||||
import java.util.HashSet
|
||||
import java.util.Collection
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.*
|
||||
import org.jetbrains.jet.compiler.CompilerPlugin
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
|
||||
class KDocGenerator(val model: KModel, val outputDir: File) {
|
||||
|
||||
fun execute(): Unit {
|
||||
println("Generating kdoc to $outputDir")
|
||||
run("allclasses-frame.html", AllClassesFrameTemplate(model, " target=\"classFrame\""))
|
||||
run("allclasses-noframe.html", AllClassesFrameTemplate(model))
|
||||
// run("constant-values.html", ConstantValuesTemplate(model))
|
||||
// run("deprecated-list.html", DeprecatedListTemplate(model))
|
||||
run("help-doc.html", HelpDocTemplate(model))
|
||||
// run("index-all.html", IndexAllTemplate(model))
|
||||
run("index.html", IndexTemplate(model))
|
||||
run("overview-frame.html", OverviewFrameTemplate(model))
|
||||
run("overview-summary.html", OverviewSummaryTemplate(model))
|
||||
run("overview-tree.html", OverviewTreeTemplate(model))
|
||||
run("package-list", PackageListTemplate(model))
|
||||
// run("serialized-form.html", SerializedFormTemplate(model))
|
||||
/**
|
||||
TODO
|
||||
*/
|
||||
for (p in model.packages) {
|
||||
run("${p.nameAsPath}/package-frame.html", PackageFrameTemplate(model, p))
|
||||
run("${p.nameAsPath}/package-summary.html", PackageSummaryTemplate(model, p))
|
||||
//run("${p.nameAsPath}/package-tree.html", PackageTreeTemplate(model, p))
|
||||
//run("${p.nameAsPath}/package-use.html", PackageUseTemplate(model, p))
|
||||
for (c in p.classes) {
|
||||
run("${c.nameAsPath}.html", ClassTemplate(model, p, c))
|
||||
}
|
||||
|
||||
val map = extensionFunctions(p.functions)
|
||||
for (e in map.entrySet()) {
|
||||
val c = e?.getKey()
|
||||
val functions = e?.getValue()
|
||||
if (c != null && functions != null) {
|
||||
run("${p.nameAsPath}/${c.simpleName}-extensions.html", ClassExtensionsTemplate(model, p, c, functions))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected fun run(fileName: String, template: TextTemplate): Unit {
|
||||
val file = File(outputDir, fileName)
|
||||
file.getParentFile()?.mkdirs()
|
||||
|
||||
log("Generating $fileName")
|
||||
template.renderTo(file)
|
||||
}
|
||||
|
||||
protected fun log(text: String) {
|
||||
println(text)
|
||||
}
|
||||
|
||||
}
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
package org.jetbrains.kotlin.doc.templates
|
||||
|
||||
import std.*
|
||||
import org.jetbrains.kotlin.template.*
|
||||
import std.io.*
|
||||
import std.util.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.model.KModel
|
||||
import org.jetbrains.kotlin.model.KPackage
|
||||
import org.jetbrains.kotlin.model.KClass
|
||||
import org.jetbrains.kotlin.model.KFunction
|
||||
import org.jetbrains.kotlin.model.KAnnotation
|
||||
|
||||
class ClassExtensionsTemplate(m: KModel, p: KPackage, k: KClass, var functions: List<KFunction>) : ClassTemplate(m, p, k) {
|
||||
|
||||
override fun pageTitle(): String = "${klass.name} Extensions fom ${pkg.name} (${model.title})"
|
||||
|
||||
override fun printBody(): Unit {
|
||||
println("""<HR>
|
||||
<!-- ======== START OF CLASS EXTENSIONS DATA ======== -->
|
||||
<H2>
|
||||
<FONT SIZE="-1">""")
|
||||
println("${pkg.name}</FONT>")
|
||||
println("<BR>")
|
||||
println("Extensions on ${klass.name}</H2>")
|
||||
println("<DL>")
|
||||
print("<DT>")
|
||||
print("extension functions on class <A HREF=\"${pkg.nameAsRelativePath}src-html/${klass.nameAsPath}.html#line.${klass.sourceLine}\"><B>${klass.name}</B></A><DT>")
|
||||
|
||||
println("from package ")
|
||||
println(link(pkg))
|
||||
println("</DL>")
|
||||
println("""</PRE>
|
||||
|
||||
<P>""")
|
||||
|
||||
printFunctionSummary(functions)
|
||||
printFunctionDetail(functions)
|
||||
|
||||
println("""<!-- ========= END OF CLASS EXTENSIONS DATA ========= -->
|
||||
<HR>
|
||||
""")
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,10 @@ import org.jetbrains.kotlin.model.KClass
|
||||
import org.jetbrains.kotlin.model.KFunction
|
||||
import org.jetbrains.kotlin.model.KAnnotation
|
||||
|
||||
class ClassTemplate(val model: KModel, pkg: KPackage, val klass: KClass) : PackageTemplateSupport(pkg) {
|
||||
open class ClassTemplate(open val model: KModel, pkg: KPackage, open val klass: KClass) : PackageTemplateSupport(pkg) {
|
||||
|
||||
open fun pageTitle(): String = "${klass.name} (${model.title})"
|
||||
|
||||
override fun render() {
|
||||
// TODO could really do with templates in multi-line strings :)
|
||||
println("""<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
@@ -21,7 +24,7 @@ class ClassTemplate(val model: KModel, pkg: KPackage, val klass: KClass) : Packa
|
||||
println("<!-- Generated by kdoc (${model.version}) on ${Date()} -->")
|
||||
println("""<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<TITLE>""")
|
||||
println("${klass.name} (${model.title})")
|
||||
println(pageTitle())
|
||||
println("""</TITLE>
|
||||
|
||||
<META NAME="date" CONTENT="2012-01-09">
|
||||
@@ -100,8 +103,74 @@ DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHO
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_top"></A>
|
||||
<!-- ========= END OF TOP NAVBAR ========= -->
|
||||
""")
|
||||
|
||||
<HR>
|
||||
printBody()
|
||||
|
||||
println("""<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||||
<A NAME="navbar_bottom"><!-- --></A>
|
||||
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">""")
|
||||
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"${pkg.nameAsRelativePath}overview-summary.html\"><FONT CLASS=\"NavBarFont1\"><B>Overview</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"package-summary.html\"><FONT CLASS=\"NavBarFont1\"><B>Package</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#FFFFFF\" CLASS=\"NavBarCell1Rev\"> <FONT CLASS=\"NavBarFont1Rev\"><B>Class</B></FONT> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"class-use/${klass.simpleName}.html\"><FONT CLASS=\"NavBarFont1\"><B>Use</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"package-tree.html\"><FONT CLASS=\"NavBarFont1\"><B>Tree</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"${pkg.nameAsRelativePath}deprecated-list.html\"><FONT CLASS=\"NavBarFont1\"><B>Deprecated</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"${pkg.nameAsRelativePath}index-all.html\"><FONT CLASS=\"NavBarFont1\"><B>Index</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"${pkg.nameAsRelativePath}help-doc.html\"><FONT CLASS=\"NavBarFont1\"><B>Help</B></FONT></A> </TD>")
|
||||
|
||||
println(""" </TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>""")
|
||||
printPrevNextClass()
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">""")
|
||||
println(" <A HREF=\"${pkg.nameAsRelativePath}index.html?${klass.nameAsPath}.html\" target=\"_top\"><B>FRAMES</B></A> ")
|
||||
println(" <A HREF=\"${klass.simpleName}.html\" target=\"_top\"><B>NO FRAMES</B></A> ")
|
||||
println(""" <SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {""")
|
||||
println(" document.writeln('<A HREF=\"${pkg.nameAsRelativePath}allclasses-noframe.html\"><B>All Classes</B></A>');")
|
||||
println(""" }
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>""")
|
||||
println(" <A HREF=\"${pkg.nameAsRelativePath}allclasses-noframe.html\"><B>All Classes</B></A>")
|
||||
println("""</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||||
SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
||||
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||||
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_bottom"></A>
|
||||
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||||
|
||||
<HR>
|
||||
Copyright © 2010-2012. All Rights Reserved.
|
||||
</BODY>
|
||||
</HTML>""")
|
||||
}
|
||||
|
||||
open fun printBody(): Unit {
|
||||
println("""<HR>
|
||||
<!-- ======== START OF CLASS DATA ======== -->
|
||||
<H2>
|
||||
<FONT SIZE="-1">""")
|
||||
@@ -177,71 +246,10 @@ DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHO
|
||||
|
||||
println("""<!-- ========= END OF CLASS DATA ========= -->
|
||||
<HR>
|
||||
|
||||
|
||||
<!-- ======= START OF BOTTOM NAVBAR ====== -->
|
||||
<A NAME="navbar_bottom"><!-- --></A>
|
||||
<A HREF="#skip-navbar_bottom" title="Skip navigation links"></A>
|
||||
<TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
|
||||
<TR>
|
||||
<TD COLSPAN=2 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
|
||||
<A NAME="navbar_bottom_firstrow"><!-- --></A>
|
||||
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
|
||||
<TR ALIGN="center" VALIGN="top">""")
|
||||
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"${pkg.nameAsRelativePath}overview-summary.html\"><FONT CLASS=\"NavBarFont1\"><B>Overview</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"package-summary.html\"><FONT CLASS=\"NavBarFont1\"><B>Package</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#FFFFFF\" CLASS=\"NavBarCell1Rev\"> <FONT CLASS=\"NavBarFont1Rev\"><B>Class</B></FONT> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"class-use/${klass.simpleName}.html\"><FONT CLASS=\"NavBarFont1\"><B>Use</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"package-tree.html\"><FONT CLASS=\"NavBarFont1\"><B>Tree</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"${pkg.nameAsRelativePath}deprecated-list.html\"><FONT CLASS=\"NavBarFont1\"><B>Deprecated</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"${pkg.nameAsRelativePath}index-all.html\"><FONT CLASS=\"NavBarFont1\"><B>Index</B></FONT></A> </TD>")
|
||||
println(" <TD BGCOLOR=\"#EEEEFF\" CLASS=\"NavBarCell1\"> <A HREF=\"${pkg.nameAsRelativePath}help-doc.html\"><FONT CLASS=\"NavBarFont1\"><B>Help</B></FONT></A> </TD>")
|
||||
|
||||
println(""" </TR>
|
||||
</TABLE>
|
||||
</TD>
|
||||
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
|
||||
</EM>
|
||||
</TD>
|
||||
</TR>
|
||||
|
||||
<TR>""")
|
||||
printPrevNextClass()
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">""")
|
||||
println(" <A HREF=\"${pkg.nameAsRelativePath}index.html?${klass.nameAsPath}.html\" target=\"_top\"><B>FRAMES</B></A> ")
|
||||
println(" <A HREF=\"${klass.simpleName}.html\" target=\"_top\"><B>NO FRAMES</B></A> ")
|
||||
println(""" <SCRIPT type="text/javascript">
|
||||
<!--
|
||||
if(window==top) {""")
|
||||
println(" document.writeln('<A HREF=\"${pkg.nameAsRelativePath}allclasses-noframe.html\"><B>All Classes</B></A>');")
|
||||
println(""" }
|
||||
//-->
|
||||
</SCRIPT>
|
||||
<NOSCRIPT>""")
|
||||
println(" <A HREF=\"${pkg.nameAsRelativePath}allclasses-noframe.html\"><B>All Classes</B></A>")
|
||||
println("""</NOSCRIPT>
|
||||
|
||||
|
||||
</FONT></TD>
|
||||
</TR>
|
||||
<TR>
|
||||
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||||
SUMMARY: <A HREF="#nested_class_summary">NESTED</A> | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
|
||||
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
|
||||
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
<A NAME="skip-navbar_bottom"></A>
|
||||
<!-- ======== END OF BOTTOM NAVBAR ======= -->
|
||||
|
||||
<HR>
|
||||
Copyright © 2010-2012. All Rights Reserved.
|
||||
</BODY>
|
||||
</HTML>""")
|
||||
""")
|
||||
}
|
||||
|
||||
fun printPrevNextClass(): Unit {
|
||||
open fun printPrevNextClass(): Unit {
|
||||
println("""<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">""")
|
||||
val prev = pkg.previous(klass)
|
||||
if (prev != null) {
|
||||
|
||||
@@ -8,16 +8,24 @@ import org.jetbrains.kotlin.model.KFunction
|
||||
import java.util.Collection
|
||||
|
||||
abstract class KDocTemplate() : TextTemplate() {
|
||||
fun href(pkg: KPackage): String {
|
||||
fun rootHref(pkg: KPackage): String {
|
||||
return if (pkg.external) {
|
||||
// TODO deal with external classes
|
||||
""
|
||||
} else relativePrefix()
|
||||
}
|
||||
|
||||
fun href(p: KPackage): String
|
||||
= "${rootHref(p)}${p.nameAsPath}/package-summary.html"
|
||||
|
||||
fun href(c: KClass): String {
|
||||
val postfix = if (c.pkg.external) "?is-external=true" else ""
|
||||
return "${href(c.pkg)}${c.nameAsPath}.html$postfix"
|
||||
return "${rootHref(c.pkg)}${c.nameAsPath}.html$postfix"
|
||||
}
|
||||
|
||||
fun extensionsHref(pkg: KPackage, c: KClass): String {
|
||||
// is inside the pkg so no need to use it...
|
||||
return "${c.nameAsPath}-extensions.html"
|
||||
}
|
||||
|
||||
fun href(f: KFunction): String {
|
||||
@@ -30,7 +38,7 @@ abstract class KDocTemplate() : TextTemplate() {
|
||||
|
||||
fun sourceHref(f: KFunction): String {
|
||||
return if (f.owner is KClass) {
|
||||
"${href(f.owner.pkg)}src-html/${f.owner.simpleName}.html#line.${f.sourceLine}"
|
||||
"${rootHref(f.owner.pkg)}src-html/${f.owner.simpleName}.html#line.${f.sourceLine}"
|
||||
} else {
|
||||
// TODO how to find the function in a package???
|
||||
""
|
||||
@@ -44,6 +52,10 @@ abstract class KDocTemplate() : TextTemplate() {
|
||||
return "<A HREF=\"${href(c)}\" title=\"${c.kind} in ${c.packageName}\">$prefix$name</A>"
|
||||
}
|
||||
|
||||
fun link(p: KPackage): String {
|
||||
return "<A HREF=\"${href(p)}\" title=\"package ${p.name}}\">${p.name}</A>"
|
||||
}
|
||||
|
||||
fun link(a: KAnnotation): String {
|
||||
val c = a.klass
|
||||
return "<A HREF=\"${href(c)}\" title=\"annotation in ${c.packageName}\">@${c.simpleName}</A>"
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ class PackageFrameTemplate(val model: KModel, p: KPackage) : PackageTemplateSupp
|
||||
for (e in map.entrySet()) {
|
||||
val c = e?.getKey()
|
||||
if (c != null) {
|
||||
println("<A HREF=\"${c.name}.html\" title=\"function in ${pkg.name}\" target=\"classFrame\"><I>${c.name}</I></A>")
|
||||
println("<A HREF=\"${extensionsHref(pkg, c)}\" title=\"extensions functions on class ${c.name} from ${pkg.name}\" target=\"classFrame\"><I>${c.name}</I></A>")
|
||||
println("<BR>")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-5
@@ -12,11 +12,7 @@ import org.jetbrains.kotlin.model.KFunction
|
||||
import org.jetbrains.kotlin.model.KAnnotation
|
||||
|
||||
|
||||
abstract class PackageTemplateSupport(private val _pkg: KPackage) : KDocTemplate() {
|
||||
|
||||
// TODO this verbosity is to work around this bug: http://youtrack.jetbrains.com/issue/KT-1398
|
||||
public val pkg: KPackage
|
||||
get() = _pkg
|
||||
abstract class PackageTemplateSupport(open val pkg: KPackage) : KDocTemplate() {
|
||||
|
||||
protected override fun relativePrefix(): String = pkg.nameAsRelativePath
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package org.jetbrains.kotlin.model
|
||||
|
||||
import std.*
|
||||
import std.util.*
|
||||
|
||||
import org.jetbrains.kotlin.doc.templates.*
|
||||
import org.jetbrains.kotlin.template.TextTemplate
|
||||
import org.jetbrains.kotlin.model.*
|
||||
|
||||
import java.io.File
|
||||
import java.util.List
|
||||
import java.util.HashSet
|
||||
import java.util.Collection
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext.*
|
||||
import org.jetbrains.jet.compiler.CompilerPlugin
|
||||
import org.jetbrains.jet.lang.psi.JetFile
|
||||
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor
|
||||
import org.jetbrains.jet.lexer.JetTokens
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor
|
||||
import org.jetbrains.jet.lang.types.JetType
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaNamespaceDescriptor
|
||||
import org.jetbrains.jet.lang.descriptors.ValueParameterDescriptor
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ExtensionReceiver
|
||||
import org.jetbrains.jet.util.slicedmap.WritableSlice
|
||||
import org.jetbrains.jet.lang.resolve.BindingContextUtils
|
||||
|
||||
|
||||
/** Base class for any compiler plugin which needs to process a KModel */
|
||||
abstract class KModelCompilerPlugin : CompilerPlugin {
|
||||
|
||||
override fun processFiles(context: BindingContext?, sources: List<JetFile?>?) {
|
||||
if (context != null && sources != null) {
|
||||
val model = KModel(context)
|
||||
model.load(sources)
|
||||
|
||||
processModel(model)
|
||||
}
|
||||
}
|
||||
|
||||
abstract fun processModel(model: KModel): Unit
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.kotlin.model;
|
||||
|
||||
/**
|
||||
* Hack around the issue of
|
||||
*/
|
||||
public class KModelHack {
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jetbrains.kotlin.model;
|
||||
|
||||
import org.jetbrains.jet.lang.psi.JetVisitor;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class KModelVisitor { // extends JetVisitor<Void, KModel> {
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user