diff options
-rw-r--r-- | ant/src/dokka.kt | 12 | ||||
-rw-r--r-- | gradle-plugin/src/main/kotlin/main.kt | 38 | ||||
-rw-r--r-- | maven-plugin/src/main/kotlin/DokkaMojo.kt | 30 | ||||
-rw-r--r-- | src/Analysis/AnalysisEnvironment.kt | 2 | ||||
-rw-r--r-- | src/Generation/FileGenerator.kt | 4 | ||||
-rw-r--r-- | src/Java/JavaDocumentationBuilder.kt | 140 | ||||
-rw-r--r-- | src/Kotlin/ContentBuilder.kt | 12 | ||||
-rw-r--r-- | src/Kotlin/DocumentationBuilder.kt | 216 | ||||
-rw-r--r-- | src/Locations/LocationService.kt | 2 | ||||
-rw-r--r-- | src/Utilities/Path.kt | 8 | ||||
-rw-r--r-- | src/main.kt | 44 | ||||
-rw-r--r-- | test/src/format/HtmlFormatTest.kt | 46 | ||||
-rw-r--r-- | test/src/format/MarkdownFormatTest.kt | 48 | ||||
-rw-r--r-- | test/src/markdown/ParserTest.kt | 42 | ||||
-rw-r--r-- | test/src/model/ClassTest.kt | 26 | ||||
-rw-r--r-- | test/src/model/CommentTest.kt | 24 | ||||
-rw-r--r-- | test/src/model/FunctionTest.kt | 4 | ||||
-rw-r--r-- | test/src/model/JavaTest.kt | 30 | ||||
-rw-r--r-- | test/src/model/LinkTest.kt | 8 | ||||
-rw-r--r-- | test/src/model/PackageTest.kt | 10 | ||||
-rw-r--r-- | test/src/model/PropertyTest.kt | 14 |
21 files changed, 380 insertions, 380 deletions
diff --git a/ant/src/dokka.kt b/ant/src/dokka.kt index 882dbdb7..6538f083 100644 --- a/ant/src/dokka.kt +++ b/ant/src/dokka.kt @@ -37,7 +37,7 @@ class DokkaAntTask(): Task() { } public fun setClasspathRef(ref: Reference) { - compileClasspath.createPath().setRefid(ref) + compileClasspath.createPath().refid = ref } public fun setSrc(src: Path) { @@ -45,7 +45,7 @@ class DokkaAntTask(): Task() { } public fun setSrcRef(ref: Reference) { - sourcePath.createPath().setRefid(ref) + sourcePath.createPath().refid = ref } public fun setSamples(samples: Path) { @@ -53,7 +53,7 @@ class DokkaAntTask(): Task() { } public fun setSamplesRef(ref: Reference) { - samplesPath.createPath().setRefid(ref) + samplesPath.createPath().refid = ref } public fun setInclude(include: Path) { @@ -85,11 +85,11 @@ class DokkaAntTask(): Task() { if (url == null) { throw BuildException("Path attribute of a <sourceLink> element is required") } - SourceLinkDefinition(File(path).getCanonicalFile().getAbsolutePath(), url, it.lineSuffix) + SourceLinkDefinition(File(path).canonicalFile.absolutePath, url, it.lineSuffix) } - val url = javaClass<DokkaAntTask>().getResource("/org/jetbrains/dokka/ant/DokkaAntTask.class") - val jarRoot = url.getPath().substringBefore("!/").removePrefix("file:") + val url = DokkaAntTask::class.java.getResource("/org/jetbrains/dokka/ant/DokkaAntTask.class") + val jarRoot = url.path.substringBefore("!/").removePrefix("file:") val generator = DokkaGenerator( AntLogger(this), diff --git a/gradle-plugin/src/main/kotlin/main.kt b/gradle-plugin/src/main/kotlin/main.kt index 418af00f..e56b2371 100644 --- a/gradle-plugin/src/main/kotlin/main.kt +++ b/gradle-plugin/src/main/kotlin/main.kt @@ -15,29 +15,29 @@ import java.util.ArrayList public open class DokkaPlugin : Plugin<Project> { override fun apply(project: Project) { - val ext = project.getExtensions().create("dokka", javaClass<DokkaExtension>()) - project.getTasks().create("dokka", javaClass<DokkaTask>()) + val ext = project.extensions.create("dokka", DokkaExtension::class.java) + project.tasks.create("dokka", DokkaTask::class.java) - ext.moduleName = project.getName() - ext.outputDirectory = File(project.getBuildDir(), "dokka").getAbsolutePath() + ext.moduleName = project.name + ext.outputDirectory = File(project.buildDir, "dokka").absolutePath } } public open class DokkaTask : DefaultTask() { init { - setGroup(JavaBasePlugin.DOCUMENTATION_GROUP) - setDescription("Generates dokka documentation for Kotlin") + group = JavaBasePlugin.DOCUMENTATION_GROUP + description = "Generates dokka documentation for Kotlin" } - TaskAction + @TaskAction fun generate() { - val project = getProject() - val conf = getProject().getExtensions().getByType(javaClass<DokkaExtension>()) - val javaPluginConvention = getProject().getConvention().getPlugin(javaClass<JavaPluginConvention>()) + val project = project + val conf = project.extensions.getByType(DokkaExtension::class.java) + val javaPluginConvention = project.convention.getPlugin(JavaPluginConvention::class.java) - val sourceSets = javaPluginConvention.getSourceSets()?.findByName(SourceSet.MAIN_SOURCE_SET_NAME) - val sourceDirectories = sourceSets?.getAllSource()?.getSrcDirs()?.filter { it.exists() } ?: emptyList() - val allConfigurations = getProject().getConfigurations() + val sourceSets = javaPluginConvention.sourceSets?.findByName(SourceSet.MAIN_SOURCE_SET_NAME) + val sourceDirectories = sourceSets?.allSource?.srcDirs?.filter { it.exists() } ?: emptyList() + val allConfigurations = project.configurations val classpath = conf.processConfigurations @@ -45,20 +45,20 @@ public open class DokkaTask : DefaultTask() { .flatMap { it } if (sourceDirectories.isEmpty()) { - getLogger().warn("No source directories found: skipping dokka generation") + logger.warn("No source directories found: skipping dokka generation") return } DokkaGenerator( - DokkaGradleLogger(getLogger()), - classpath.map { it.getAbsolutePath() }, - sourceDirectories.map { it.getAbsolutePath() }, + DokkaGradleLogger(logger), + classpath.map { it.absolutePath }, + sourceDirectories.map { it.absolutePath }, conf.samples, conf.includes, conf.moduleName, conf.outputDirectory, conf.outputFormat, - conf.linkMappings.map { SourceLinkDefinition(project.file(it.dir).getAbsolutePath(), it.url, it.suffix) }, + conf.linkMappings.map { SourceLinkDefinition(project.file(it.dir).absolutePath, it.url, it.suffix) }, false ).generate() } @@ -76,7 +76,7 @@ public open class DokkaExtension { fun linkMapping(closure: Closure<Any?>) { val mapping = LinkMapping() - closure.setDelegate(mapping) + closure.delegate = mapping closure.call() if (mapping.dir.isEmpty()) { diff --git a/maven-plugin/src/main/kotlin/DokkaMojo.kt b/maven-plugin/src/main/kotlin/DokkaMojo.kt index 80f00c42..fae9d856 100644 --- a/maven-plugin/src/main/kotlin/DokkaMojo.kt +++ b/maven-plugin/src/main/kotlin/DokkaMojo.kt @@ -9,53 +9,53 @@ import org.jetbrains.dokka.DokkaGenerator import org.jetbrains.dokka.SourceLinkDefinition public class SourceLinkMapItem { - Parameter(name = "dir", required = true) + @Parameter(name = "dir", required = true) var dir: String = "" - Parameter(name = "url", required = true) + @Parameter(name = "url", required = true) var url: String = "" - Parameter(name = "urlSuffix") + @Parameter(name = "urlSuffix") var urlSuffix: String? = null } -Mojo(name = "dokka", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) +@Mojo(name = "dokka", defaultPhase = LifecyclePhase.PRE_SITE, threadSafe = true, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true) public class DokkaMojo : AbstractMojo() { - Parameter(required = true, defaultValue = "\${project.compileSourceRoots}") + @Parameter(required = true, defaultValue = "\${project.compileSourceRoots}") var sourceDirectories: List<String> = emptyList() - Parameter + @Parameter var samplesDirs: List<String> = emptyList() - Parameter + @Parameter var includeDirs: List<String> = emptyList() - Parameter(required = true, defaultValue = "\${project.compileClasspathElements}") + @Parameter(required = true, defaultValue = "\${project.compileClasspathElements}") var classpath: List<String> = emptyList() - Parameter(required = true, defaultValue = "\${project.basedir}/target/dokka") + @Parameter(required = true, defaultValue = "\${project.basedir}/target/dokka") var outputDir: String = "" - Parameter(required = true, defaultValue = "html") + @Parameter(required = true, defaultValue = "html") var outputFormat: String = "html" - Parameter + @Parameter var sourceLinks: Array<SourceLinkMapItem> = emptyArray() - Parameter(required = true, defaultValue = "\${project.artifactId}") + @Parameter(required = true, defaultValue = "\${project.artifactId}") var moduleName: String = "" - Parameter(required = false, defaultValue = "false") + @Parameter(required = false, defaultValue = "false") var skip: Boolean = false override fun execute() { if (skip) { - getLog().info("Dokka skip parameter is true so no dokka output will be produced") + log.info("Dokka skip parameter is true so no dokka output will be produced") return } val gen = DokkaGenerator( - MavenDokkaLogger(getLog()), + MavenDokkaLogger(log), classpath, sourceDirectories, samplesDirs, diff --git a/src/Analysis/AnalysisEnvironment.kt b/src/Analysis/AnalysisEnvironment.kt index 060a3170..dfea46d2 100644 --- a/src/Analysis/AnalysisEnvironment.kt +++ b/src/Analysis/AnalysisEnvironment.kt @@ -71,7 +71,7 @@ public class AnalysisEnvironment(val messageCollector: MessageCollector, body: A val projectComponentManager = environment.project as MockComponentManager val moduleManager = CoreModuleManager(environment.project, this) - CoreApplicationEnvironment.registerComponentInstance(projectComponentManager.getPicoContainer(), + CoreApplicationEnvironment.registerComponentInstance(projectComponentManager.picoContainer, ModuleManager::class.java, moduleManager) projectComponentManager.registerService(ProjectFileIndex::class.java, diff --git a/src/Generation/FileGenerator.kt b/src/Generation/FileGenerator.kt index abe4257f..40645b51 100644 --- a/src/Generation/FileGenerator.kt +++ b/src/Generation/FileGenerator.kt @@ -14,7 +14,7 @@ public class FileGenerator(val signatureGenerator: LanguageService, public fun buildPages(nodes: Iterable<DocumentationNode>) { for ((location, items) in nodes.groupBy { locationService.location(it) }) { val file = location.file - file.getParentFile()?.mkdirs() + file.parentFile?.mkdirs() FileOutputStream(file).use { OutputStreamWriter(it, Charsets.UTF_8).use { it.write(formatService.format(location, items)) @@ -30,7 +30,7 @@ public class FileGenerator(val signatureGenerator: LanguageService, } for ((location, items) in nodes.groupBy { locationService.location(it) }) { val file = outlineService.getOutlineFileName(location) - file.getParentFile()?.mkdirs() + file.parentFile?.mkdirs() FileOutputStream(file).use { OutputStreamWriter(it, Charsets.UTF_8).use { it.write(outlineService.formatOutline(location, items)) diff --git a/src/Java/JavaDocumentationBuilder.kt b/src/Java/JavaDocumentationBuilder.kt index 13bed113..217a6a41 100644 --- a/src/Java/JavaDocumentationBuilder.kt +++ b/src/Java/JavaDocumentationBuilder.kt @@ -11,11 +11,11 @@ import org.jsoup.nodes.TextNode public class JavaDocumentationBuilder(private val options: DocumentationOptions, private val refGraph: NodeReferenceGraph) { fun appendFile(file: PsiJavaFile, module: DocumentationModule) { - if (file.getClasses().all { skipElement(it) }) { + if (file.classes.all { skipElement(it) }) { return } - val packageNode = module.findOrCreatePackageNode(file.getPackageName(), emptyMap()) - packageNode.appendChildren(file.getClasses()) { build() } + val packageNode = module.findOrCreatePackageNode(file.packageName, emptyMap()) + packageNode.appendChildren(file.classes) { build() } } data class JavadocParseResult(val content: Content, val deprecatedContent: Content?) @@ -26,9 +26,9 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, var deprecatedContent: Content? = null val para = ContentParagraph() result.append(para) - para.convertJavadocElements(docComment.getDescriptionElements().dropWhile { it.getText().trim().isEmpty() }) - docComment.getTags().forEach { tag -> - when(tag.getName()) { + para.convertJavadocElements(docComment.descriptionElements.dropWhile { it.text.trim().isEmpty() }) + docComment.tags.forEach { tag -> + when(tag.name) { "see" -> result.convertSeeTag(tag) "deprecated" -> { deprecatedContent = Content() @@ -36,7 +36,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, } else -> { val subjectName = tag.getSubjectName() - val section = result.addSection(javadocSectionDisplayName(tag.getName()), subjectName) + val section = result.addSection(javadocSectionDisplayName(tag.name), subjectName) section.convertJavadocElements(tag.contentElements()) } @@ -46,10 +46,10 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, } private fun PsiDocTag.contentElements(): Iterable<PsiElement> { - val tagValueElements = getChildren() - .dropWhile { it.getNode().getElementType() == JavaDocTokenType.DOC_TAG_NAME } + val tagValueElements = children + .dropWhile { it.node.elementType == JavaDocTokenType.DOC_TAG_NAME } .dropWhile { it is PsiWhiteSpace } - .filterNot { it.getNode().getElementType() == JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS } + .filterNot { it.node.elementType == JavaDocTokenType.DOC_COMMENT_LEADING_ASTERISKS } return if (getSubjectName() != null) tagValueElements.dropWhile { it is PsiDocTagValue } else tagValueElements } @@ -59,7 +59,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, if (it is PsiInlineDocTag) { htmlBuilder.append(convertInlineDocTag(it)) } else { - htmlBuilder.append(it.getText()) + htmlBuilder.append(it.text) } } val doc = Jsoup.parse(htmlBuilder.toString().trimStart()) @@ -114,9 +114,9 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, } val seeSection = findSectionByTag("See Also") ?: addSection("See Also", null) val linkSignature = resolveLink(linkElement) - val text = ContentText(linkElement.getText()) + val text = ContentText(linkElement.text) if (linkSignature != null) { - val linkNode = ContentNodeLazyLink(tag.getValueElement()!!.getText(), { -> refGraph.lookup(linkSignature)}) + val linkNode = ContentNodeLazyLink(tag.valueElement!!.text, { -> refGraph.lookup(linkSignature)}) linkNode.append(text) seeSection.append(linkNode) } else { @@ -124,35 +124,35 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, } } - private fun convertInlineDocTag(tag: PsiInlineDocTag) = when (tag.getName()) { + private fun convertInlineDocTag(tag: PsiInlineDocTag) = when (tag.name) { "link", "linkplain" -> { val valueElement = tag.linkElement() val linkSignature = resolveLink(valueElement) if (linkSignature != null) { - val labelText = tag.getDataElements().firstOrNull { it is PsiDocToken }?.getText() ?: valueElement!!.getText() + val labelText = tag.dataElements.firstOrNull { it is PsiDocToken }?.text ?: valueElement!!.text val link = "<a docref=\"$linkSignature\">${labelText.htmlEscape()}</a>" - if (tag.getName() == "link") "<code>$link</code>" else link + if (tag.name == "link") "<code>$link</code>" else link } else if (valueElement != null) { - valueElement.getText() + valueElement.text } else { "" } } "code", "literal" -> { val text = StringBuilder() - tag.getDataElements().forEach { text.append(it.getText()) } + tag.dataElements.forEach { text.append(it.text) } val escaped = text.toString().trimStart().htmlEscape() - if (tag.getName() == "code") "<code>$escaped</code>" else escaped + if (tag.name == "code") "<code>$escaped</code>" else escaped } - else -> tag.getText() + else -> tag.text } private fun PsiDocTag.linkElement(): PsiElement? = - getValueElement() ?: getDataElements().firstOrNull { it !is PsiWhiteSpace } + valueElement ?: dataElements.firstOrNull { it !is PsiWhiteSpace } private fun resolveLink(valueElement: PsiElement?): String? { - val target = valueElement?.getReference()?.resolve() + val target = valueElement?.reference?.resolve() if (target != null) { return getSignature(target) } @@ -160,8 +160,8 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, } fun PsiDocTag.getSubjectName(): String? { - if (getName() == "param" || getName() == "throws" || getName() == "exception") { - return getValueElement()?.getText() + if (name == "param" || name == "throws" || name == "exception") { + return valueElement?.text } return null } @@ -188,32 +188,32 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, } private fun getSignature(element: PsiElement?) = when(element) { - is PsiClass -> element.getQualifiedName() - is PsiField -> element.getContainingClass()!!.getQualifiedName() + "#" + element.getName() + is PsiClass -> element.qualifiedName + is PsiField -> element.containingClass!!.qualifiedName + "#" + element.name is PsiMethod -> - element.getContainingClass()!!.getQualifiedName() + "#" + element.getName() + "(" + - element.getParameterList().getParameters().map { it.getType().typeSignature() }.join(",") + ")" + element.containingClass!!.qualifiedName + "#" + element.name + "(" + + element.parameterList.parameters.map { it.type.typeSignature() }.join(",") + ")" else -> null } private fun PsiType.typeSignature(): String = when(this) { - is PsiArrayType -> "Array<${getComponentType().typeSignature()}>" + is PsiArrayType -> "Array<${componentType.typeSignature()}>" else -> mapTypeName(this) } fun DocumentationNode(element: PsiNamedElement, kind: Kind, - name: String = element.getName() ?: "<anonymous>"): DocumentationNode { - val (docComment, deprecatedContent) = parseDocumentation((element as? PsiDocCommentOwner)?.getDocComment()) + name: String = element.name ?: "<anonymous>"): DocumentationNode { + val (docComment, deprecatedContent) = parseDocumentation((element as? PsiDocCommentOwner)?.docComment) val node = DocumentationNode(name, docComment, kind) if (element is PsiModifierListOwner) { node.appendModifiers(element) - val modifierList = element.getModifierList() + val modifierList = element.modifierList if (modifierList != null) { - modifierList.getAnnotations().filter { !ignoreAnnotation(it) }.forEach { + modifierList.annotations.filter { !ignoreAnnotation(it) }.forEach { val annotation = it.build() node.append(annotation, - if (it.getQualifiedName() == "java.lang.Deprecated") DocumentationReference.Kind.Deprecation else DocumentationReference.Kind.Annotation) + if (it.qualifiedName == "java.lang.Deprecated") DocumentationReference.Kind.Deprecation else DocumentationReference.Kind.Annotation) } } } @@ -224,7 +224,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, return node } - fun ignoreAnnotation(annotation: PsiAnnotation) = when(annotation.getQualifiedName()) { + fun ignoreAnnotation(annotation: PsiAnnotation) = when(annotation.qualifiedName) { "java.lang.SuppressWarnings" -> true else -> false } @@ -246,7 +246,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, (element.hasModifierProperty(PsiModifier.PRIVATE) || element.hasModifierProperty(PsiModifier.PACKAGE_LOCAL)) private fun hasSuppressTag(element: Any) = - element is PsiDocCommentOwner && element.getDocComment()?.let { it.findTagByName("suppress") != null } ?: false + element is PsiDocCommentOwner && element.docComment?.let { it.findTagByName("suppress") != null } ?: false fun DocumentationNode.appendMembers<T : Any>(elements: Array<T>, buildFn: T.() -> DocumentationNode) = appendChildren(elements, DocumentationReference.Kind.Member, buildFn) @@ -256,23 +256,23 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, fun PsiClass.build(): DocumentationNode { val kind = when { - isInterface() -> DocumentationNode.Kind.Interface - isEnum() -> DocumentationNode.Kind.Enum - isAnnotationType() -> DocumentationNode.Kind.AnnotationClass + isInterface -> DocumentationNode.Kind.Interface + isEnum -> DocumentationNode.Kind.Enum + isAnnotationType -> DocumentationNode.Kind.AnnotationClass else -> DocumentationNode.Kind.Class } val node = DocumentationNode(this, kind) - getSuperTypes().filter { !ignoreSupertype(it) }.forEach { + superTypes.filter { !ignoreSupertype(it) }.forEach { node.appendType(it, Kind.Supertype) val superClass = it.resolve() if (superClass != null) { link(superClass, node, DocumentationReference.Kind.Inheritor) } } - node.appendDetails(getTypeParameters()) { build() } - node.appendMembers(getMethods()) { build() } - node.appendMembers(getFields()) { build() } - node.appendMembers(getInnerClasses()) { build() } + node.appendDetails(typeParameters) { build() } + node.appendMembers(methods) { build() } + node.appendMembers(fields) { build() } + node.appendMembers(innerClasses) { build() } register(this, node) return node } @@ -282,9 +282,9 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, fun PsiClassType.isClass(qName: String): Boolean { val shortName = qName.substringAfterLast('.') - if (getClassName() == shortName) { + if (className == shortName) { val psiClass = resolve() - return psiClass?.getQualifiedName() == qName + return psiClass?.qualifiedName == qName } return false } @@ -294,7 +294,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, if (!hasModifierProperty(PsiModifier.FINAL)) { node.appendTextNode("var", Kind.Modifier) } - node.appendType(getType()) + node.appendType(type) register(this, node) return node } @@ -307,27 +307,27 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, fun PsiMethod.build(): DocumentationNode { val node = DocumentationNode(this, nodeKind(), - if (isConstructor()) "<init>" else getName()) + if (isConstructor) "<init>" else name) - if (!isConstructor()) { - node.appendType(getReturnType()) + if (!isConstructor) { + node.appendType(returnType) } - node.appendDetails(getParameterList().getParameters()) { build() } - node.appendDetails(getTypeParameters()) { build() } + node.appendDetails(parameterList.parameters) { build() } + node.appendDetails(typeParameters) { build() } register(this, node) return node } private fun PsiMethod.nodeKind(): Kind = when { - isConstructor() -> Kind.Constructor + isConstructor -> Kind.Constructor hasModifierProperty(PsiModifier.STATIC) -> Kind.CompanionObjectFunction else -> Kind.Function } fun PsiParameter.build(): DocumentationNode { val node = DocumentationNode(this, Kind.Parameter) - node.appendType(getType()) - if (getType() is PsiEllipsisType) { + node.appendType(type) + if (type is PsiEllipsisType) { node.appendTextNode("vararg", Kind.Annotation, DocumentationReference.Kind.Annotation) } return node @@ -335,13 +335,13 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, fun PsiTypeParameter.build(): DocumentationNode { val node = DocumentationNode(this, Kind.TypeParameter) - getExtendsListTypes().forEach { node.appendType(it, Kind.UpperBound) } - getImplementsListTypes().forEach { node.appendType(it, Kind.UpperBound) } + extendsListTypes.forEach { node.appendType(it, Kind.UpperBound) } + implementsListTypes.forEach { node.appendType(it, Kind.UpperBound) } return node } fun DocumentationNode.appendModifiers(element: PsiModifierListOwner) { - val modifierList = element.getModifierList() + val modifierList = element.modifierList if (modifierList == null) { return } @@ -350,7 +350,7 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, appendTextNode(it, Kind.Modifier) } } - if ((element is PsiClass || (element is PsiMethod && !element.isConstructor())) && + if ((element is PsiClass || (element is PsiMethod && !element.isConstructor)) && !element.hasModifierProperty(PsiModifier.FINAL)) { appendTextNode("open", Kind.Modifier) } @@ -367,34 +367,34 @@ public class JavaDocumentationBuilder(private val options: DocumentationOptions, val name = mapTypeName(this) val node = DocumentationNode(name, Content.Empty, kind) if (this is PsiClassType) { - node.appendDetails(getParameters()) { build(Kind.Type) } + node.appendDetails(parameters) { build(Kind.Type) } link(node, resolve()) } if (this is PsiArrayType && this !is PsiEllipsisType) { - node.append(getComponentType().build(Kind.Type), DocumentationReference.Kind.Detail) + node.append(componentType.build(Kind.Type), DocumentationReference.Kind.Detail) } return node } private fun mapTypeName(psiType: PsiType): String = when (psiType) { PsiType.VOID -> "Unit" - is PsiPrimitiveType -> psiType.getCanonicalText().capitalize() + is PsiPrimitiveType -> psiType.canonicalText.capitalize() is PsiClassType -> { val psiClass = psiType.resolve() - if (psiClass?.getQualifiedName() == "java.lang.Object") "Any" else psiType.getClassName() + if (psiClass?.qualifiedName == "java.lang.Object") "Any" else psiType.className } - is PsiEllipsisType -> mapTypeName(psiType.getComponentType()) + is PsiEllipsisType -> mapTypeName(psiType.componentType) is PsiArrayType -> "Array" - else -> psiType.getCanonicalText() + else -> psiType.canonicalText } fun PsiAnnotation.build(): DocumentationNode { - val node = DocumentationNode(getNameReferenceElement()?.getText() ?: "<?>", Content.Empty, DocumentationNode.Kind.Annotation) - getParameterList().getAttributes().forEach { - val parameter = DocumentationNode(it.getName() ?: "value", Content.Empty, DocumentationNode.Kind.Parameter) - val value = it.getValue() + val node = DocumentationNode(nameReferenceElement?.text ?: "<?>", Content.Empty, DocumentationNode.Kind.Annotation) + parameterList.attributes.forEach { + val parameter = DocumentationNode(it.name ?: "value", Content.Empty, DocumentationNode.Kind.Parameter) + val value = it.value if (value != null) { - val valueText = (value as? PsiLiteralExpression)?.getValue() as? String ?: value.getText() + val valueText = (value as? PsiLiteralExpression)?.value as? String ?: value.text val valueNode = DocumentationNode(valueText, Content.Empty, DocumentationNode.Kind.Value) parameter.append(valueNode, DocumentationReference.Kind.Detail) } diff --git a/src/Kotlin/ContentBuilder.kt b/src/Kotlin/ContentBuilder.kt index ff6eafb0..95ff9f91 100644 --- a/src/Kotlin/ContentBuilder.kt +++ b/src/Kotlin/ContentBuilder.kt @@ -156,13 +156,13 @@ fun DocumentationBuilder.functionBody(descriptor: DeclarationDescriptor, functio val text = when (psiElement) { is JetDeclarationWithBody -> ContentBlockCode().let() { - val bodyExpression = psiElement.getBodyExpression() + val bodyExpression = psiElement.bodyExpression when (bodyExpression) { - is JetBlockExpression -> bodyExpression.getText().removeSurrounding("{", "}") - else -> bodyExpression!!.getText() + is JetBlockExpression -> bodyExpression.text.removeSurrounding("{", "}") + else -> bodyExpression!!.text } } - else -> psiElement.getText() + else -> psiElement.text } val lines = text.trimEnd().split("\n".toRegex()).toTypedArray().filterNot { it.length() == 0 } @@ -180,14 +180,14 @@ private fun DocumentationBuilder.resolveInScope(functionName: String, scope: Jet for (part in parts) { // short name val symbolName = Name.guess(part) - val partSymbol = currentScope.getAllDescriptors().filter { it.getName() == symbolName }.firstOrNull() + val partSymbol = currentScope.getAllDescriptors().filter { it.name == symbolName }.firstOrNull() if (partSymbol == null) { symbol = null break } currentScope = if (partSymbol is ClassDescriptor) - partSymbol.getDefaultType().getMemberScope() + partSymbol.defaultType.memberScope else getResolutionScope(resolutionFacade, partSymbol).asJetScope() symbol = partSymbol diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 4729fbab..9321e5ca 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -79,13 +79,13 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, if (kdoc is KDocSection) { val tags = kdoc.getTags() tags.forEach { - when (it.getName()) { + when (it.name) { "sample" -> content.append(functionBody(descriptor, it.getSubjectName())) "see" -> content.addTagToSeeAlso(descriptor, it) else -> { - val section = content.addSection(javadocSectionDisplayName(it.getName()), it.getSubjectName()) + val section = content.addSection(javadocSectionDisplayName(it.name), it.getSubjectName()) val sectionContent = it.getContent() val markdownNode = parseMarkdown(sectionContent) buildInlineContentTo(markdownNode, section, { href -> resolveContentLink(descriptor, href) }) @@ -104,17 +104,17 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, if (descriptor !is CallableMemberDescriptor) { return null } - val name = descriptor.getName().asString() + val name = descriptor.name.asString() if (name == "equals" || name == "hashCode" || name == "toString") { var deepestDescriptor: CallableMemberDescriptor = descriptor - while (!deepestDescriptor.getOverriddenDescriptors().isEmpty()) { - deepestDescriptor = deepestDescriptor.getOverriddenDescriptors().first() + while (!deepestDescriptor.overriddenDescriptors.isEmpty()) { + deepestDescriptor = deepestDescriptor.overriddenDescriptors.first() } - if (DescriptorUtils.getFqName(deepestDescriptor.getContainingDeclaration()).asString() == "kotlin.Any") { + if (DescriptorUtils.getFqName(deepestDescriptor.containingDeclaration).asString() == "kotlin.Any") { val anyClassDescriptors = session.getTopLevelClassDescriptors(FqName.fromSegments(listOf("kotlin", "Any")), NoLookupLocation.UNSORTED) anyClassDescriptors.forEach { - val anyMethod = it.getMemberScope(listOf()).getFunctions(descriptor.getName(), NoLookupLocation.UNSORTED).single() + val anyMethod = it.getMemberScope(listOf()).getFunctions(descriptor.name, NoLookupLocation.UNSORTED).single() val kdoc = KDocFinder.findKDoc(anyMethod) if (kdoc != null) { return kdoc @@ -125,51 +125,51 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, return null } - fun DeclarationDescriptor.isDeprecated(): Boolean = getAnnotations().any { - DescriptorUtils.getFqName(it.getType().getConstructor().getDeclarationDescriptor()!!).asString() == "kotlin.Deprecated" - } || (this is ConstructorDescriptor && getContainingDeclaration().isDeprecated()) + fun DeclarationDescriptor.isDeprecated(): Boolean = annotations.any { + DescriptorUtils.getFqName(it.type.constructor.declarationDescriptor!!).asString() == "kotlin.Deprecated" + } || (this is ConstructorDescriptor && containingDeclaration.isDeprecated()) fun DeclarationDescriptor.signature(): String = when(this) { is ClassDescriptor, is PackageFragmentDescriptor -> DescriptorUtils.getFqName(this).asString() - is PropertyDescriptor -> getContainingDeclaration().signature() + "#" + getName() + receiverSignature() - is FunctionDescriptor -> getContainingDeclaration().signature() + "#" + getName() + parameterSignature() - is ValueParameterDescriptor -> getContainingDeclaration().signature() + ":" + getName() - is TypeParameterDescriptor -> getContainingDeclaration().signature() + "<" + getName() + is PropertyDescriptor -> containingDeclaration.signature() + "#" + name + receiverSignature() + is FunctionDescriptor -> containingDeclaration.signature() + "#" + name + parameterSignature() + is ValueParameterDescriptor -> containingDeclaration.signature() + ":" + name + is TypeParameterDescriptor -> containingDeclaration.signature() + "<" + name else -> throw UnsupportedOperationException("Don't know how to calculate signature for $this") } fun PropertyDescriptor.receiverSignature(): String { - val receiver = getExtensionReceiverParameter() + val receiver = extensionReceiverParameter if (receiver != null) { - return "#" + receiver.getType().signature() + return "#" + receiver.type.signature() } return "" } fun CallableMemberDescriptor.parameterSignature(): String { - val params = getValueParameters().map { it.getType() }.toArrayList() - val extensionReceiver = getExtensionReceiverParameter() + val params = valueParameters.map { it.type }.toArrayList() + val extensionReceiver = extensionReceiverParameter if (extensionReceiver != null) { - params.add(0, extensionReceiver.getType()) + params.add(0, extensionReceiver.type) } return "(" + params.map { it.signature() }.join() + ")" } fun JetType.signature(): String { - val declarationDescriptor = getConstructor().getDeclarationDescriptor() ?: return "<null>" + val declarationDescriptor = constructor.declarationDescriptor ?: return "<null>" val typeName = DescriptorUtils.getFqName(declarationDescriptor).asString() - if (typeName == "Array" && getArguments().size() == 1) { - return "Array<" + getArguments().first().getType().signature() + ">" + if (typeName == "Array" && arguments.size() == 1) { + return "Array<" + arguments.first().type.signature() + ">" } return typeName } fun DeclarationDescriptor.sourceLocation(): String? { if (this is DeclarationDescriptorWithSource) { - val psi = (this.getSource() as? PsiSourceElement)?.getPsi() + val psi = (this.source as? PsiSourceElement)?.getPsi() if (psi != null) { - val fileName = psi.getContainingFile().getName() + val fileName = psi.containingFile.name val lineNumber = psi.lineNumber() return if (lineNumber != null) "$fileName:$lineNumber" else fileName } @@ -208,8 +208,8 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, return null } val symbol = symbols.first() - if (symbol is CallableMemberDescriptor && symbol.getKind() == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { - return symbol.getOverriddenDescriptors().firstOrNull() + if (symbol is CallableMemberDescriptor && symbol.kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE) { + return symbol.overriddenDescriptors.firstOrNull() } return symbol } @@ -244,7 +244,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, fun DocumentationNode<T>(descriptor: T, kind: Kind): DocumentationNode where T : DeclarationDescriptor, T : Named { val doc = parseDocumentation(descriptor) - val node = DocumentationNode(descriptor.getName().asString(), doc, kind).withModifiers(descriptor) + val node = DocumentationNode(descriptor.name.asString(), doc, kind).withModifiers(descriptor) return node } @@ -259,10 +259,10 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } fun DocumentationNode.appendModality(descriptor: MemberDescriptor) { - var modality = descriptor.getModality() + var modality = descriptor.modality if (modality == Modality.OPEN) { - val containingClass = descriptor.getContainingDeclaration() as? ClassDescriptor - if (containingClass?.getModality() == Modality.FINAL) { + val containingClass = descriptor.containingDeclaration as? ClassDescriptor + if (containingClass?.modality == Modality.FINAL) { modality = Modality.FINAL } } @@ -271,22 +271,22 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } fun DocumentationNode.appendVisibility(descriptor: DeclarationDescriptorWithVisibility) { - val modifier = descriptor.getVisibility().toString() + val modifier = descriptor.visibility.toString() appendTextNode(modifier, DocumentationNode.Kind.Modifier) } fun DocumentationNode.appendSupertypes(descriptor: ClassDescriptor) { - val superTypes = descriptor.getTypeConstructor().getSupertypes() + val superTypes = descriptor.typeConstructor.supertypes for (superType in superTypes) { if (!ignoreSupertype(superType)) { appendType(superType, DocumentationNode.Kind.Supertype) - link(superType?.getConstructor()?.getDeclarationDescriptor(), descriptor, DocumentationReference.Kind.Inheritor) + link(superType?.constructor?.declarationDescriptor, descriptor, DocumentationReference.Kind.Inheritor) } } } private fun ignoreSupertype(superType: JetType): Boolean { - val superClass = superType.getConstructor().getDeclarationDescriptor() as? ClassDescriptor + val superClass = superType.constructor.declarationDescriptor as? ClassDescriptor if (superClass != null) { val fqName = DescriptorUtils.getFqNameSafe(superClass).asString() return fqName == "kotlin.Annotation" || fqName == "kotlin.Enum" || fqName == "kotlin.Any" @@ -295,31 +295,31 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } fun DocumentationNode.appendProjection(projection: TypeProjection, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type) { - appendType(projection.getType(), kind, projection.getProjectionKind().label) + appendType(projection.type, kind, projection.projectionKind.label) } fun DocumentationNode.appendType(jetType: JetType?, kind: DocumentationNode.Kind = DocumentationNode.Kind.Type, prefix: String = "") { if (jetType == null) return - val classifierDescriptor = jetType.getConstructor().getDeclarationDescriptor() + val classifierDescriptor = jetType.constructor.declarationDescriptor val name = when (classifierDescriptor) { is ClassDescriptor -> { - if (classifierDescriptor.isCompanionObject()) { - classifierDescriptor.getContainingDeclaration().getName().asString() + - "." + classifierDescriptor.getName().asString() + if (classifierDescriptor.isCompanionObject) { + classifierDescriptor.containingDeclaration.name.asString() + + "." + classifierDescriptor.name.asString() } else { - classifierDescriptor.getName().asString() + classifierDescriptor.name.asString() } } - is Named -> classifierDescriptor.getName().asString() + is Named -> classifierDescriptor.name.asString() else -> "<anonymous>" } val node = DocumentationNode(name, Content.Empty, kind) if (prefix != "") { node.appendTextNode(prefix, Kind.Modifier) } - if (jetType.isMarkedNullable()) { + if (jetType.isMarkedNullable) { node.appendTextNode("?", Kind.NullabilityModifier) } if (classifierDescriptor != null && !classifierDescriptor.isBoringBuiltinClass()) { @@ -327,7 +327,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } append(node, DocumentationReference.Kind.Detail) - for (typeArgument in jetType.getArguments()) + for (typeArgument in jetType.arguments) node.appendProjection(typeArgument) } @@ -366,7 +366,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, fun DocumentationNode.appendChild(descriptor: DeclarationDescriptor, kind: DocumentationReference.Kind): DocumentationNode? { // do not include generated code - if (descriptor is CallableMemberDescriptor && descriptor.getKind() != CallableMemberDescriptor.Kind.DECLARATION) + if (descriptor is CallableMemberDescriptor && descriptor.kind != CallableMemberDescriptor.Kind.DECLARATION) return null if (descriptor.isDocumented()) { @@ -380,7 +380,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, private fun DeclarationDescriptor.isDocumented(): Boolean { return (options.includeNonPublic || this !is MemberDescriptor - || this.getVisibility() in visibleToDocumentation) && + || this.visibility in visibleToDocumentation) && !isDocumentationSuppressed() && (!options.skipDeprecated || !isDeprecated()) } @@ -451,10 +451,10 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, else -> throw IllegalStateException("Descriptor $this is not known") } - fun ScriptDescriptor.build(): DocumentationNode = getClassDescriptor().build() + fun ScriptDescriptor.build(): DocumentationNode = classDescriptor.build() fun ClassDescriptor.build(): DocumentationNode { - val kind = when (getKind()) { + val kind = when (kind) { ClassKind.OBJECT -> Kind.Object ClassKind.INTERFACE -> Kind.Interface ClassKind.ENUM_CLASS -> Kind.Enum @@ -465,48 +465,48 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, val node = DocumentationNode(this, kind) node.appendSupertypes(this) if (getKind() != ClassKind.OBJECT && getKind() != ClassKind.ENUM_ENTRY) { - node.appendInPageChildren(getTypeConstructor().getParameters(), DocumentationReference.Kind.Detail) + node.appendInPageChildren(typeConstructor.parameters, DocumentationReference.Kind.Detail) val constructorsToDocument = if (getKind() == ClassKind.ENUM_CLASS) - getConstructors().filter { it.getValueParameters().size() > 0 } + constructors.filter { it.valueParameters.size() > 0 } else - getConstructors() + constructors node.appendChildren(constructorsToDocument, DocumentationReference.Kind.Member) } - val members = getDefaultType().getMemberScope().getAllDescriptors().filter { it != getCompanionObjectDescriptor() } + val members = defaultType.memberScope.getAllDescriptors().filter { it != companionObjectDescriptor } node.appendChildren(members, DocumentationReference.Kind.Member) - val companionObjectDescriptor = getCompanionObjectDescriptor() + val companionObjectDescriptor = companionObjectDescriptor if (companionObjectDescriptor != null) { - node.appendChildren(companionObjectDescriptor.getDefaultType().getMemberScope().getAllDescriptors(), + node.appendChildren(companionObjectDescriptor.defaultType.memberScope.getAllDescriptors(), DocumentationReference.Kind.Member) } node.appendAnnotations(this) node.appendModifiers(this) - node.appendSourceLink(getSource()) + node.appendSourceLink(source) register(this, node) return node } fun ConstructorDescriptor.build(): DocumentationNode { val node = DocumentationNode(this, Kind.Constructor) - node.appendInPageChildren(getValueParameters(), DocumentationReference.Kind.Detail) + node.appendInPageChildren(valueParameters, DocumentationReference.Kind.Detail) register(this, node) return node } private fun CallableMemberDescriptor.inCompanionObject(): Boolean { - val containingDeclaration = getContainingDeclaration() - if ((containingDeclaration as? ClassDescriptor)?.isCompanionObject() ?: false) { + val containingDeclaration = containingDeclaration + if ((containingDeclaration as? ClassDescriptor)?.isCompanionObject ?: false) { return true } - val receiver = getExtensionReceiverParameter() - return (receiver?.getType()?.getConstructor()?.getDeclarationDescriptor() as? ClassDescriptor)?.isCompanionObject() ?: false + val receiver = extensionReceiverParameter + return (receiver?.type?.constructor?.declarationDescriptor as? ClassDescriptor)?.isCompanionObject ?: false } fun CallableMemberDescriptor.getExtensionClassDescriptor(): ClassifierDescriptor? { - val extensionReceiver = getExtensionReceiverParameter() + val extensionReceiver = extensionReceiverParameter if (extensionReceiver != null) { - val type = extensionReceiver.getType() - return type.getConstructor().getDeclarationDescriptor() as? ClassDescriptor + val type = extensionReceiver.type + return type.constructor.declarationDescriptor as? ClassDescriptor } return null } @@ -518,16 +518,16 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, val node = DocumentationNode(this, if (inCompanionObject()) Kind.CompanionObjectFunction else Kind.Function) - node.appendInPageChildren(getTypeParameters(), DocumentationReference.Kind.Detail) - getExtensionReceiverParameter()?.let { node.appendChild(it, DocumentationReference.Kind.Detail) } - node.appendInPageChildren(getValueParameters(), DocumentationReference.Kind.Detail) - node.appendType(getReturnType()) + node.appendInPageChildren(typeParameters, DocumentationReference.Kind.Detail) + extensionReceiverParameter?.let { node.appendChild(it, DocumentationReference.Kind.Detail) } + node.appendInPageChildren(valueParameters, DocumentationReference.Kind.Detail) + node.appendType(returnType) node.appendAnnotations(this) node.appendModifiers(this) - node.appendSourceLink(getSource()) + node.appendSourceLink(source) node.appendOperatorOverloadNote(this) - getOverriddenDescriptors().forEach { + overriddenDescriptors.forEach { addOverrideLink(it, this) } @@ -536,11 +536,11 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } fun addOverrideLink(baseClassFunction: CallableMemberDescriptor, overridingFunction: CallableMemberDescriptor) { - val source = baseClassFunction.getOriginal().getSource().getPsi() + val source = baseClassFunction.original.source.getPsi() if (source != null) { link(overridingFunction, baseClassFunction, DocumentationReference.Kind.Override) } else { - baseClassFunction.getOverriddenDescriptors().forEach { + baseClassFunction.overriddenDescriptors.forEach { addOverrideLink(it, overridingFunction) } } @@ -563,36 +563,36 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } fun FunctionDescriptor.getImplementedOperator(): String? { - var arity = getValueParameters().size() - if (getContainingDeclaration() is ClassDescriptor) { + var arity = valueParameters.size() + if (containingDeclaration is ClassDescriptor) { arity++ } - if (getExtensionReceiverParameter() != null) { + if (extensionReceiverParameter != null) { arity++ } val token = if (arity == 2) { - OperatorConventions.BINARY_OPERATION_NAMES.inverse()[getName()] ?: - OperatorConventions.ASSIGNMENT_OPERATIONS.inverse()[getName()] ?: - OperatorConventions.BOOLEAN_OPERATIONS.inverse()[getName()] + OperatorConventions.BINARY_OPERATION_NAMES.inverse()[name] ?: + OperatorConventions.ASSIGNMENT_OPERATIONS.inverse()[name] ?: + OperatorConventions.BOOLEAN_OPERATIONS.inverse()[name] } else if (arity == 1) { - OperatorConventions.UNARY_OPERATION_NAMES.inverse()[getName()] + OperatorConventions.UNARY_OPERATION_NAMES.inverse()[name] } else null if (token is JetSingleValueToken) { - return token.getValue() + return token.value } - val name = getName().asString() + val name = name.asString() if (arity == 2 && name == "contains") { return "in" } if (arity >= 2 && (name == "get" || name == "set")) { return "[]" } - if (arity == 2 && name == "equals" && getValueParameters().size() == 1 && - KotlinBuiltIns.isNullableAny(getValueParameters().first().getType())) { + if (arity == 2 && name == "equals" && valueParameters.size() == 1 && + KotlinBuiltIns.isNullableAny(valueParameters.first().type)) { return "==" } return null @@ -600,27 +600,27 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, fun PropertyDescriptor.build(): DocumentationNode { val node = DocumentationNode(this, if (inCompanionObject()) Kind.CompanionObjectProperty else Kind.Property) - node.appendInPageChildren(getTypeParameters(), DocumentationReference.Kind.Detail) - getExtensionReceiverParameter()?.let { node.appendChild(it, DocumentationReference.Kind.Detail) } - node.appendType(getReturnType()) + node.appendInPageChildren(typeParameters, DocumentationReference.Kind.Detail) + extensionReceiverParameter?.let { node.appendChild(it, DocumentationReference.Kind.Detail) } + node.appendType(returnType) node.appendAnnotations(this) node.appendModifiers(this) - node.appendSourceLink(getSource()) - if (isVar()) { + node.appendSourceLink(source) + if (isVar) { node.appendTextNode("var", DocumentationNode.Kind.Modifier) } - getGetter()?.let { - if (!it.isDefault()) { + getter?.let { + if (!it.isDefault) { node.addAccessorDocumentation(parseDocumentation(it), "Getter") } } - getSetter()?.let { - if (!it.isDefault()) { + setter?.let { + if (!it.isDefault) { node.addAccessorDocumentation(parseDocumentation(it), "Setter") } } - getOverriddenDescriptors().forEach { + overriddenDescriptors.forEach { addOverrideLink(it, this) } @@ -646,9 +646,9 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, val node = DocumentationNode(this, Kind.Parameter) node.appendType(varargElementType ?: type) if (declaresDefaultValue()) { - val psi = getSource().getPsi() as? JetParameter + val psi = source.getPsi() as? JetParameter if (psi != null) { - val defaultValueText = psi.getDefaultValue()?.getText() + val defaultValueText = psi.defaultValue?.text if (defaultValueText != null) { node.appendTextNode(defaultValueText, Kind.Value) } @@ -662,8 +662,8 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, fun TypeParameterDescriptor.build(): DocumentationNode { val doc = parseDocumentation(this) - val name = getName().asString() - val prefix = getVariance().label + val name = name.asString() + val prefix = variance.label val node = DocumentationNode(name, doc, DocumentationNode.Kind.TypeParameter) if (prefix != "") { @@ -671,13 +671,13 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } val builtIns = KotlinBuiltIns.getInstance() - for (constraint in getUpperBounds()) { - if (constraint == builtIns.getDefaultBound()) + for (constraint in upperBounds) { + if (constraint == builtIns.defaultBound) continue node.appendType(constraint, Kind.UpperBound) } - for (constraint in getLowerBounds()) { + for (constraint in lowerBounds) { if (KotlinBuiltIns.isNothing(constraint)) continue node.appendType(constraint, Kind.LowerBound) @@ -686,30 +686,30 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, } fun ReceiverParameterDescriptor.build(): DocumentationNode { - var receiverClass: DeclarationDescriptor = getType().getConstructor().getDeclarationDescriptor()!! - if ((receiverClass as? ClassDescriptor)?.isCompanionObject() ?: false) { - receiverClass = receiverClass.getContainingDeclaration()!! + var receiverClass: DeclarationDescriptor = type.constructor.declarationDescriptor!! + if ((receiverClass as? ClassDescriptor)?.isCompanionObject ?: false) { + receiverClass = receiverClass.containingDeclaration!! } link(receiverClass, - getContainingDeclaration(), + containingDeclaration, DocumentationReference.Kind.Extension) - val node = DocumentationNode(getName().asString(), Content.Empty, Kind.Receiver) - node.appendType(getType()) + val node = DocumentationNode(name.asString(), Content.Empty, Kind.Receiver) + node.appendType(type) return node } fun AnnotationDescriptor.build(): DocumentationNode? { - val annotationClass = getType().getConstructor().getDeclarationDescriptor() + val annotationClass = type.constructor.declarationDescriptor if (annotationClass == null || ErrorUtils.isError(annotationClass)) { return null } - val node = DocumentationNode(annotationClass.getName().asString(), Content.Empty, DocumentationNode.Kind.Annotation) - val arguments = getAllValueArguments().toList().sortedBy { it.first.getIndex() } + val node = DocumentationNode(annotationClass.name.asString(), Content.Empty, DocumentationNode.Kind.Annotation) + val arguments = allValueArguments.toList().sortedBy { it.first.index } arguments.forEach { val valueNode = it.second.toDocumentationNode() if (valueNode != null) { - val paramNode = DocumentationNode(it.first.getName().asString(), Content.Empty, DocumentationNode.Kind.Parameter) + val paramNode = DocumentationNode(it.first.name.asString(), Content.Empty, DocumentationNode.Kind.Parameter) paramNode.append(valueNode, DocumentationReference.Kind.Detail) node.append(paramNode, DocumentationReference.Kind.Detail) } diff --git a/src/Locations/LocationService.kt b/src/Locations/LocationService.kt index 7d0b8b56..a43054ce 100644 --- a/src/Locations/LocationService.kt +++ b/src/Locations/LocationService.kt @@ -26,7 +26,7 @@ public data class FileLocation(val file: File): Location { if (file.path.substringBeforeLast(".") == other.file.path.substringBeforeLast(".") && anchor == null) { return "." } - val ownerFolder = file.getParentFile()!! + val ownerFolder = file.parentFile!! val relativePath = ownerFolder.getRelativePath(other.file).path return if (anchor == null) relativePath else relativePath + "#" + anchor } diff --git a/src/Utilities/Path.kt b/src/Utilities/Path.kt index 24420ec7..973163a8 100644 --- a/src/Utilities/Path.kt +++ b/src/Utilities/Path.kt @@ -3,13 +3,13 @@ package org.jetbrains.dokka import java.io.* fun File.getRelativePath(name: File): File { - val parent = getParentFile() + val parent = parentFile if (parent == null) throw IOException("No common directory"); - val basePath = getCanonicalPath() + File.separator; - val targetPath = name.getCanonicalPath(); + val basePath = canonicalPath + File.separator; + val targetPath = name.canonicalPath; if (targetPath.startsWith(basePath)) { return File(targetPath.substring(basePath.length())) @@ -18,4 +18,4 @@ fun File.getRelativePath(name: File): File { } } -fun File.appendExtension(extension: String) = if (extension.isEmpty()) this else File(getPath() + "." + extension) +fun File.appendExtension(extension: String) = if (extension.isEmpty()) this else File(path + "." + extension) diff --git a/src/main.kt b/src/main.kt index 4a0c22f8..5cbfff1a 100644 --- a/src/main.kt +++ b/src/main.kt @@ -19,46 +19,46 @@ import org.jetbrains.kotlin.utils.PathUtil import java.io.File class DokkaArguments { - Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)") - ValueDescription("<path>") + @Argument(value = "src", description = "Source file or directory (allows many paths separated by the system path separator)") + @ValueDescription("<path>") public var src: String = "" - Argument(value = "srcLink", description = "Mapping between a source directory and a Web site for browsing the code") - ValueDescription("<path>=<url>[#lineSuffix]") + @Argument(value = "srcLink", description = "Mapping between a source directory and a Web site for browsing the code") + @ValueDescription("<path>=<url>[#lineSuffix]") public var srcLink: String = "" - Argument(value = "include", description = "Markdown files to load (allows many paths separated by the system path separator)") - ValueDescription("<path>") + @Argument(value = "include", description = "Markdown files to load (allows many paths separated by the system path separator)") + @ValueDescription("<path>") public var include: String = "" - Argument(value = "samples", description = "Source root for samples") - ValueDescription("<path>") + @Argument(value = "samples", description = "Source root for samples") + @ValueDescription("<path>") public var samples: String = "" - Argument(value = "output", description = "Output directory path") - ValueDescription("<path>") + @Argument(value = "output", description = "Output directory path") + @ValueDescription("<path>") public var outputDir: String = "out/doc/" - Argument(value = "format", description = "Output format (text, html, markdown, jekyll, kotlin-website)") - ValueDescription("<name>") + @Argument(value = "format", description = "Output format (text, html, markdown, jekyll, kotlin-website)") + @ValueDescription("<name>") public var outputFormat: String = "html" - Argument(value = "module", description = "Name of the documentation module") - ValueDescription("<name>") + @Argument(value = "module", description = "Name of the documentation module") + @ValueDescription("<name>") public var moduleName: String = "" - Argument(value = "classpath", description = "Classpath for symbol resolution") - ValueDescription("<path>") + @Argument(value = "classpath", description = "Classpath for symbol resolution") + @ValueDescription("<path>") public var classpath: String = "" - Argument(value = "nodeprecated", description = "Exclude deprecated members from documentation") + @Argument(value = "nodeprecated", description = "Exclude deprecated members from documentation") public var nodeprecated: Boolean = false } private fun parseSourceLinkDefinition(srcLink: String): SourceLinkDefinition { val (path, urlAndLine) = srcLink.split('=') - return SourceLinkDefinition(File(path).getAbsolutePath(), + return SourceLinkDefinition(File(path).absolutePath, urlAndLine.substringBefore("#"), urlAndLine.substringAfter("#", "").let { if (it.isEmpty()) null else "#" + it }) } @@ -142,7 +142,7 @@ class DokkaGenerator(val logger: DokkaLogger, val environment = createAnalysisEnvironment() logger.info("Module: ${moduleName}") - logger.info("Output: ${File(outputDir).getAbsolutePath()}") + logger.info("Output: ${File(outputDir).absolutePath}") logger.info("Sources: ${environment.sources.join()}") logger.info("Classpath: ${environment.classpath.joinToString()}") @@ -201,7 +201,7 @@ class DokkaGenerator(val logger: DokkaLogger, } fun isSample(file: PsiFile): Boolean { - val sourceFile = File(file.getVirtualFile()!!.getPath()) + val sourceFile = File(file.virtualFile!!.path) return samples.none { sample -> val canonicalSample = File(sample).canonicalPath val canonicalSource = sourceFile.canonicalPath @@ -218,7 +218,7 @@ fun buildDocumentationModule(environment: AnalysisEnvironment, logger: DokkaLogger): DocumentationModule { val documentation = environment.withContext { environment, resolutionFacade, session -> val fragmentFiles = environment.getSourceFiles().filter(filesToDocumentFilter) - val fragments = fragmentFiles.map { session.getPackageFragment(it.getPackageFqName()) }.filterNotNull().distinct() + val fragments = fragmentFiles.map { session.getPackageFragment(it.packageFqName) }.filterNotNull().distinct() val refGraph = NodeReferenceGraph() val documentationBuilder = DocumentationBuilder(resolutionFacade, session, options, refGraph, logger) @@ -254,7 +254,7 @@ fun KotlinCoreEnvironment.getJavaSourceFiles(): List<PsiJavaFile> { val result = arrayListOf<PsiJavaFile>() val localFileSystem = VirtualFileManager.getInstance().getFileSystem("file") sourceRoots.forEach { sourceRoot -> - sourceRoot.getAbsoluteFile().walkTopDown().forEach { + sourceRoot.absoluteFile.walkTopDown().forEach { val vFile = localFileSystem.findFileByPath(it.path) if (vFile != null) { val psiFile = PsiManager.getInstance(project).findFile(vFile) diff --git a/test/src/format/HtmlFormatTest.kt b/test/src/format/HtmlFormatTest.kt index 3d744b95..5c7a63b3 100644 --- a/test/src/format/HtmlFormatTest.kt +++ b/test/src/format/HtmlFormatTest.kt @@ -11,37 +11,37 @@ import java.io.File public class HtmlFormatTest { private val htmlService = HtmlFormatService(InMemoryLocationService, KotlinLanguageService()) - Test fun classWithCompanionObject() { + @Test fun classWithCompanionObject() { verifyOutput("test/data/format/classWithCompanionObject.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun htmlEscaping() { + @Test fun htmlEscaping() { verifyOutput("test/data/format/htmlEscaping.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun overloads() { + @Test fun overloads() { verifyOutput("test/data/format/overloads.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members) } } - Test fun overloadsWithDescription() { + @Test fun overloadsWithDescription() { verifyOutput("test/data/format/overloadsWithDescription.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun overloadsWithDifferentDescriptions() { + @Test fun overloadsWithDifferentDescriptions() { verifyOutput("test/data/format/overloadsWithDifferentDescriptions.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun deprecated() { + @Test fun deprecated() { verifyOutput("test/data/format/deprecated.kt", ".package.html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members) } @@ -50,85 +50,85 @@ public class HtmlFormatTest { } } - Test fun brokenLink() { + @Test fun brokenLink() { verifyOutput("test/data/format/brokenLink.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun codeSpan() { + @Test fun codeSpan() { verifyOutput("test/data/format/codeSpan.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun parenthesis() { + @Test fun parenthesis() { verifyOutput("test/data/format/parenthesis.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun bracket() { + @Test fun bracket() { verifyOutput("test/data/format/bracket.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun see() { + @Test fun see() { verifyOutput("test/data/format/see.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun tripleBackticks() { + @Test fun tripleBackticks() { verifyOutput("test/data/format/tripleBackticks.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun typeLink() { + @Test fun typeLink() { verifyOutput("test/data/format/typeLink.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar"} ) } } - Test fun parameterAnchor() { + @Test fun parameterAnchor() { verifyOutput("test/data/format/parameterAnchor.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaSupertypeLink() { + @Test fun javaSupertypeLink() { verifyOutput("test/data/format/javaSupertype.java", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "C"}.members.filter { it.name == "Bar"} ) } } - Test fun javaLinkTag() { + @Test fun javaLinkTag() { verifyOutput("test/data/format/javaLinkTag.java", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaLinkTagWithLabel() { + @Test fun javaLinkTagWithLabel() { verifyOutput("test/data/format/javaLinkTagWithLabel.java", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaSeeTag() { + @Test fun javaSeeTag() { verifyOutput("test/data/format/javaSeeTag.java", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaDeprecated() { + @Test fun javaDeprecated() { verifyOutput("test/data/format/javaDeprecated.java", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "Foo" }.members.filter { it.name == "foo" }) } } - Test fun crossLanguageKotlinExtendsJava() { + @Test fun crossLanguageKotlinExtendsJava() { verifyOutput(arrayOf(KotlinSourceRoot("test/data/format/crossLanguage/kotlinExtendsJava/Bar.kt"), JavaSourceRoot(File("test/data/format/crossLanguage/kotlinExtendsJava"))), ".html") { model, output -> @@ -136,19 +136,19 @@ public class HtmlFormatTest { } } - Test fun orderedList() { + @Test fun orderedList() { verifyOutput("test/data/format/orderedList.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } } - Test fun linkWithLabel() { + @Test fun linkWithLabel() { verifyOutput("test/data/format/linkWithLabel.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } } - Test fun entity() { + @Test fun entity() { verifyOutput("test/data/format/entity.kt", ".html") { model, output -> htmlService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } diff --git a/test/src/format/MarkdownFormatTest.kt b/test/src/format/MarkdownFormatTest.kt index 88003051..0df25fd5 100644 --- a/test/src/format/MarkdownFormatTest.kt +++ b/test/src/format/MarkdownFormatTest.kt @@ -7,25 +7,25 @@ import org.junit.Test public class MarkdownFormatTest { private val markdownService = MarkdownFormatService(InMemoryLocationService, KotlinLanguageService()) - Test fun emptyDescription() { + @Test fun emptyDescription() { verifyOutput("test/data/format/emptyDescription.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun classWithCompanionObject() { + @Test fun classWithCompanionObject() { verifyOutput("test/data/format/classWithCompanionObject.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun annotations() { + @Test fun annotations() { verifyOutput("test/data/format/annotations.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun annotationClass() { + @Test fun annotationClass() { verifyOutput("test/data/format/annotationClass.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } @@ -37,7 +37,7 @@ public class MarkdownFormatTest { } } - Test fun extensions() { + @Test fun extensions() { verifyOutput("test/data/format/extensions.kt", ".package.md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members) } @@ -46,7 +46,7 @@ public class MarkdownFormatTest { } } - Test fun enumClass() { + @Test fun enumClass() { verifyOutput("test/data/format/enumClass.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } @@ -57,13 +57,13 @@ public class MarkdownFormatTest { } } - Test fun varargsFunction() { + @Test fun varargsFunction() { verifyOutput("test/data/format/varargsFunction.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun overridingFunction() { + @Test fun overridingFunction() { verifyOutput("test/data/format/overridingFunction.kt", ".md") { model, output -> val classMembers = model.members.single().members.first { it.name == "D" }.members markdownService.appendNodes(tempLocation, output, classMembers.filter { it.name == "f" }) @@ -71,98 +71,98 @@ public class MarkdownFormatTest { } - Test fun propertyVar() { + @Test fun propertyVar() { verifyOutput("test/data/format/propertyVar.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun functionWithDefaultParameter() { + @Test fun functionWithDefaultParameter() { verifyOutput("test/data/format/functionWithDefaultParameter.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun accessor() { + @Test fun accessor() { verifyOutput("test/data/format/accessor.kt", ".md") { model, output -> val propertyNode = model.members.single().members.first { it.name == "C" }.members.filter { it.name == "x" } markdownService.appendNodes(tempLocation, output, propertyNode) } } - Test fun paramTag() { + @Test fun paramTag() { verifyOutput("test/data/format/paramTag.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun throwsTag() { + @Test fun throwsTag() { verifyOutput("test/data/format/throwsTag.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun typeParameterBounds() { + @Test fun typeParameterBounds() { verifyOutput("test/data/format/typeParameterBounds.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun typeParameterVariance() { + @Test fun typeParameterVariance() { verifyOutput("test/data/format/typeParameterVariance.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun typeProjectionVariance() { + @Test fun typeProjectionVariance() { verifyOutput("test/data/format/typeProjectionVariance.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javadocHtml() { + @Test fun javadocHtml() { verifyOutput("test/data/format/javadocHtml.java", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaCodeLiteralTags() { + @Test fun javaCodeLiteralTags() { verifyOutput("test/data/format/javaCodeLiteralTags.java", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaCodeInParam() { + @Test fun javaCodeInParam() { verifyOutput("test/data/format/javaCodeInParam.java", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun javaSpaceInAuthor() { + @Test fun javaSpaceInAuthor() { verifyOutput("test/data/format/javaSpaceInAuthor.java", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun nullability() { + @Test fun nullability() { verifyOutput("test/data/format/nullability.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members) } } - Test fun operatorOverloading() { + @Test fun operatorOverloading() { verifyOutput("test/data/format/operatorOverloading.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members.single { it.name == "C" }.members.filter { it.name == "plus" }) } } - Test fun javadocOrderedList() { + @Test fun javadocOrderedList() { verifyOutput("test/data/format/javadocOrderedList.java", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Bar" }) } } - Test fun companionObjectExtension() { + @Test fun companionObjectExtension() { verifyOutput("test/data/format/companionObjectExtension.kt", ".md") { model, output -> markdownService.appendNodes(tempLocation, output, model.members.single().members.filter { it.name == "Foo" }) } diff --git a/test/src/markdown/ParserTest.kt b/test/src/markdown/ParserTest.kt index 50c18f08..62dd7a1f 100644 --- a/test/src/markdown/ParserTest.kt +++ b/test/src/markdown/ParserTest.kt @@ -6,7 +6,7 @@ import org.jetbrains.dokka.toTestString import org.jetbrains.dokka.parseMarkdown import org.junit.Ignore -Ignore public class ParserTest { +@Ignore public class ParserTest { fun runTestFor(text : String) { println("MD: ---") println(text) @@ -16,27 +16,27 @@ Ignore public class ParserTest { println() } - Test fun text() { + @Test fun text() { runTestFor("text") } - Test fun textWithSpaces() { + @Test fun textWithSpaces() { runTestFor("text and string") } - Test fun textWithColon() { + @Test fun textWithColon() { runTestFor("text and string: cool!") } - Test fun link() { + @Test fun link() { runTestFor("text [links]") } - Test fun linkWithHref() { + @Test fun linkWithHref() { runTestFor("text [links](http://google.com)") } - Test fun multiline() { + @Test fun multiline() { runTestFor( """ text @@ -45,7 +45,7 @@ string """) } - Test fun para() { + @Test fun para() { runTestFor( """ paragraph number @@ -56,14 +56,14 @@ number two """) } - Test fun bulletList() { + @Test fun bulletList() { runTestFor( """* list item 1 * list item 2 """) } - Test fun bulletListWithLines() { + @Test fun bulletListWithLines() { runTestFor( """ * list item 1 @@ -73,7 +73,7 @@ number two """) } - Test fun bulletListStrong() { + @Test fun bulletListStrong() { runTestFor( """ * list *item* 1 @@ -83,47 +83,47 @@ number two """) } - Test fun emph() { + @Test fun emph() { runTestFor("*text*") } - Test fun directive() { + @Test fun directive() { runTestFor("A text \${code with.another.value} with directive") } - Test fun emphAndEmptySection() { + @Test fun emphAndEmptySection() { runTestFor("*text*\n\$sec:\n") } - Test fun emphAndSection() { + @Test fun emphAndSection() { runTestFor("*text*\n\$sec: some text\n") } - Test fun emphAndBracedSection() { + @Test fun emphAndBracedSection() { runTestFor("Text *bold* text \n\${sec}: some text") } - Test fun section() { + @Test fun section() { runTestFor( "Plain text \n\$one: Summary \n\${two}: Description with *emphasis* \n\${An example of a section}: Example") } - Test fun anonymousSection() { + @Test fun anonymousSection() { runTestFor("Summary\n\nDescription\n") } - Test fun specialSection() { + @Test fun specialSection() { runTestFor( "Plain text \n\$\$summary: Summary \n\${\$description}: Description \n\${\$An example of a section}: Example") } - Test fun emptySection() { + @Test fun emptySection() { runTestFor( "Plain text \n\$summary:") } val b = "$" - Test fun pair() { + @Test fun pair() { runTestFor( """Represents a generic pair of two values. diff --git a/test/src/model/ClassTest.kt b/test/src/model/ClassTest.kt index 8c3adb7f..24503273 100644 --- a/test/src/model/ClassTest.kt +++ b/test/src/model/ClassTest.kt @@ -8,7 +8,7 @@ import kotlin.test.assertEquals import kotlin.test.assertTrue public class ClassTest { - Test fun emptyClass() { + @Test fun emptyClass() { verifyModel("test/data/classes/emptyClass.kt") { model -> with(model.members.single().members.single()) { assertEquals(DocumentationNode.Kind.Class, kind) @@ -20,7 +20,7 @@ public class ClassTest { } } - Test fun emptyObject() { + @Test fun emptyObject() { verifyModel("test/data/classes/emptyObject.kt") { model -> with(model.members.single().members.single()) { assertEquals(DocumentationNode.Kind.Object, kind) @@ -32,7 +32,7 @@ public class ClassTest { } } - Test fun classWithConstructor() { + @Test fun classWithConstructor() { verifyModel("test/data/classes/classWithConstructor.kt") { model -> with (model.members.single().members.single()) { assertEquals(DocumentationNode.Kind.Class, kind) @@ -62,7 +62,7 @@ public class ClassTest { } } - Test fun classWithFunction() { + @Test fun classWithFunction() { verifyModel("test/data/classes/classWithFunction.kt") { model -> with(model.members.single().members.single()) { assertEquals(DocumentationNode.Kind.Class, kind) @@ -92,7 +92,7 @@ public class ClassTest { } } - Test fun classWithProperty() { + @Test fun classWithProperty() { verifyModel("test/data/classes/classWithProperty.kt") { model -> with(model.members.single().members.single()) { assertEquals(DocumentationNode.Kind.Class, kind) @@ -122,7 +122,7 @@ public class ClassTest { } } - Test fun classWithCompanionObject() { + @Test fun classWithCompanionObject() { verifyModel("test/data/classes/classWithCompanionObject.kt") { model -> with(model.members.single().members.single()) { assertEquals(DocumentationNode.Kind.Class, kind) @@ -176,7 +176,7 @@ public class ClassTest { } } - Test fun annotatedClassWithAnnotationParameters() { + @Test fun annotatedClassWithAnnotationParameters() { verifyModel("test/data/classes/annotatedClassWithAnnotationParameters.kt") { model -> with(model.members.single().members.single()) { with(deprecation!!) { @@ -197,7 +197,7 @@ public class ClassTest { } } - Test fun javaAnnotationClass() { + @Test fun javaAnnotationClass() { verifyModel("test/data/classes/javaAnnotationClass.kt") { model -> with(model.members.single().members.single()) { assertEquals(1, annotations.count()) @@ -218,7 +218,7 @@ public class ClassTest { } } - Test fun notOpenClass() { + @Test fun notOpenClass() { verifyModel("test/data/classes/notOpenClass.kt") { model -> with(model.members.single().members.first { it.name == "D"}.members.first { it.name == "f" }) { val modifiers = details(DocumentationNode.Kind.Modifier) @@ -231,7 +231,7 @@ public class ClassTest { } } - Test fun indirectOverride() { + @Test fun indirectOverride() { verifyModel("test/data/classes/indirectOverride.kt") { model -> with(model.members.single().members.first { it.name == "E"}.members.first { it.name == "foo" }) { val modifiers = details(DocumentationNode.Kind.Modifier) @@ -244,7 +244,7 @@ public class ClassTest { } } - Test fun innerClass() { + @Test fun innerClass() { verifyPackageMember("test/data/classes/innerClass.kt") { cls -> val innerClass = cls.members.single { it.name == "D" } val modifiers = innerClass.details(DocumentationNode.Kind.Modifier) @@ -253,7 +253,7 @@ public class ClassTest { } } - Test fun companionObjectExtension() { + @Test fun companionObjectExtension() { verifyModel("test/data/classes/companionObjectExtension.kt") { model -> val pkg = model.members.single() val cls = pkg.members.single { it.name == "Foo" } @@ -262,7 +262,7 @@ public class ClassTest { } } - Test fun secondaryConstructor() { + @Test fun secondaryConstructor() { verifyPackageMember("test/data/classes/secondaryConstructor.kt") { cls -> val constructors = cls.members(DocumentationNode.Kind.Constructor) assertEquals(2, constructors.size()) diff --git a/test/src/model/CommentTest.kt b/test/src/model/CommentTest.kt index 98585b18..c4d867fb 100644 --- a/test/src/model/CommentTest.kt +++ b/test/src/model/CommentTest.kt @@ -5,7 +5,7 @@ import kotlin.test.* import org.jetbrains.dokka.* public class CommentTest { - Test fun emptyDoc() { + @Test fun emptyDoc() { verifyModel("test/data/comments/emptyDoc.kt") { model -> with(model.members.single().members.single()) { assertEquals(Content.Empty, content) @@ -13,7 +13,7 @@ public class CommentTest { } } - Test fun emptyDocButComment() { + @Test fun emptyDocButComment() { verifyModel("test/data/comments/emptyDocButComment.kt") { model -> with(model.members.single().members.single()) { assertEquals(Content.Empty, content) @@ -21,7 +21,7 @@ public class CommentTest { } } - Test fun multilineDoc() { + @Test fun multilineDoc() { verifyModel("test/data/comments/multilineDoc.kt") { model -> with(model.members.single().members.single()) { assertEquals("doc1", content.summary.toTestString()) @@ -30,7 +30,7 @@ public class CommentTest { } } - Test fun multilineDocWithComment() { + @Test fun multilineDocWithComment() { verifyModel("test/data/comments/multilineDocWithComment.kt") { model -> with(model.members.single().members.single()) { assertEquals("doc1", content.summary.toTestString()) @@ -39,7 +39,7 @@ public class CommentTest { } } - Test fun oneLineDoc() { + @Test fun oneLineDoc() { verifyModel("test/data/comments/oneLineDoc.kt") { model -> with(model.members.single().members.single()) { assertEquals("doc", content.summary.toTestString()) @@ -47,7 +47,7 @@ public class CommentTest { } } - Test fun oneLineDocWithComment() { + @Test fun oneLineDocWithComment() { verifyModel("test/data/comments/oneLineDocWithComment.kt") { model -> with(model.members.single().members.single()) { assertEquals("doc", content.summary.toTestString()) @@ -55,7 +55,7 @@ public class CommentTest { } } - Test fun oneLineDocWithEmptyLine() { + @Test fun oneLineDocWithEmptyLine() { verifyModel("test/data/comments/oneLineDocWithEmptyLine.kt") { model -> with(model.members.single().members.single()) { assertEquals("doc", content.summary.toTestString()) @@ -63,7 +63,7 @@ public class CommentTest { } } - Test fun emptySection() { + @Test fun emptySection() { verifyModel("test/data/comments/emptySection.kt") { model -> with(model.members.single().members.single()) { assertEquals("Summary", content.summary.toTestString()) @@ -76,7 +76,7 @@ public class CommentTest { } } - Test fun section1() { + @Test fun section1() { verifyModel("test/data/comments/section1.kt") { model -> with(model.members.single().members.single()) { assertEquals("Summary", content.summary.toTestString()) @@ -89,7 +89,7 @@ public class CommentTest { } } - Test fun section2() { + @Test fun section2() { verifyModel("test/data/comments/section2.kt") { model -> with(model.members.single().members.single()) { assertEquals("Summary", content.summary.toTestString()) @@ -106,7 +106,7 @@ public class CommentTest { } } - Test fun multilineSection() { + @Test fun multilineSection() { verifyModel("test/data/comments/multilineSection.kt") { model -> with(model.members.single().members.single()) { assertEquals("Summary", content.summary.toTestString()) @@ -120,7 +120,7 @@ line two""", toTestString()) } } - Test fun directive() { + @Test fun directive() { verifyModel("test/data/comments/directive.kt") { model -> with(model.members.single().members.first()) { assertEquals("Summary", content.summary.toTestString()) diff --git a/test/src/model/FunctionTest.kt b/test/src/model/FunctionTest.kt index 734675de..fc3ebae5 100644 --- a/test/src/model/FunctionTest.kt +++ b/test/src/model/FunctionTest.kt @@ -189,7 +189,7 @@ Documentation""", content.description.toTestString()) } } - Test fun annotatedFunctionWithAnnotationParameters() { + @Test fun annotatedFunctionWithAnnotationParameters() { verifyModel("test/data/functions/annotatedFunctionWithAnnotationParameters.kt") { model -> with(model.members.single().members.single()) { assertEquals(1, annotations.count()) @@ -211,7 +211,7 @@ Documentation""", content.description.toTestString()) } } - Test fun functionWithDefaultParameter() { + @Test fun functionWithDefaultParameter() { verifyModel("test/data/functions/functionWithDefaultParameter.kt") { model -> with(model.members.single().members.single()) { with(details.elementAt(2)) { diff --git a/test/src/model/JavaTest.kt b/test/src/model/JavaTest.kt index 3129bcc0..e74945c4 100644 --- a/test/src/model/JavaTest.kt +++ b/test/src/model/JavaTest.kt @@ -5,7 +5,7 @@ import org.jetbrains.dokka.* import org.junit.* public class JavaTest { - Test fun function() { + @Test fun function() { verifyPackageMember("test/data/java/member.java") { cls -> assertEquals("Test", cls.name) assertEquals(DocumentationNode.Kind.Class, cls.kind) @@ -43,7 +43,7 @@ public class JavaTest { } } - Test fun memberWithModifiers() { + @Test fun memberWithModifiers() { verifyPackageMember("test/data/java/memberWithModifiers.java") { cls -> assertEquals("abstract", cls.details[0].name) with(cls.members.single { it.name == "fn" }) { @@ -55,7 +55,7 @@ public class JavaTest { } } - Test fun superClass() { + @Test fun superClass() { verifyPackageMember("test/data/java/superClass.java") { cls -> val superTypes = cls.details(DocumentationNode.Kind.Supertype) assertEquals(2, superTypes.size()) @@ -64,7 +64,7 @@ public class JavaTest { } } - Test fun arrayType() { + @Test fun arrayType() { verifyPackageMember("test/data/java/arrayType.java") { cls -> with(cls.members.single()) { val type = detail(DocumentationNode.Kind.Type) @@ -79,7 +79,7 @@ public class JavaTest { } } - Test fun typeParameter() { + @Test fun typeParameter() { verifyPackageMember("test/data/java/typeParameter.java") { cls -> val typeParameters = cls.details(DocumentationNode.Kind.TypeParameter) with(typeParameters.single()) { @@ -98,7 +98,7 @@ public class JavaTest { } } - Test fun constructors() { + @Test fun constructors() { verifyPackageMember("test/data/java/constructors.java") { cls -> val constructors = cls.members(DocumentationNode.Kind.Constructor) assertEquals(2, constructors.size()) @@ -108,14 +108,14 @@ public class JavaTest { } } - Test fun innerClass() { + @Test fun innerClass() { verifyPackageMember("test/data/java/innerClass.java") { cls -> val innerClass = cls.members(DocumentationNode.Kind.Class).single() assertEquals("D", innerClass.name) } } - Test fun varargs() { + @Test fun varargs() { verifyPackageMember("test/data/java/varargs.java") { cls -> val fn = cls.members(DocumentationNode.Kind.Function).single() val param = fn.detail(DocumentationNode.Kind.Parameter) @@ -126,7 +126,7 @@ public class JavaTest { } } - Test fun fields() { + @Test fun fields() { verifyPackageMember("test/data/java/field.java") { cls -> val i = cls.members(DocumentationNode.Kind.Property).single { it.name == "i" } assertEquals("Int", i.detail(DocumentationNode.Kind.Type).name) @@ -137,14 +137,14 @@ public class JavaTest { } } - Test fun staticMethod() { + @Test fun staticMethod() { verifyPackageMember("test/data/java/staticMethod.java") { cls -> val m = cls.members(DocumentationNode.Kind.CompanionObjectFunction).single { it.name == "foo" } assertFalse("static" in m.details(DocumentationNode.Kind.Modifier).map { it.name }) } } - Test fun annotatedAnnotation() { + @Test fun annotatedAnnotation() { verifyPackageMember("test/data/java/annotatedAnnotation.java") { cls -> assertEquals(2, cls.annotations.size()) with(cls.annotations[0]) { @@ -161,7 +161,7 @@ public class JavaTest { } } - Test fun deprecation() { + @Test fun deprecation() { verifyPackageMember("test/data/java/deprecation.java") { cls -> val fn = cls.members(DocumentationNode.Kind.Function).single() with(fn.deprecation!!) { @@ -178,14 +178,14 @@ public class JavaTest { } } - Test fun javaLangObject() { + @Test fun javaLangObject() { verifyPackageMember("test/data/java/javaLangObject.java") { cls -> val fn = cls.members(DocumentationNode.Kind.Function).single() assertEquals("Any", fn.detail(DocumentationNode.Kind.Type).name) } } - Test fun enumValues() { + @Test fun enumValues() { verifyPackageMember("test/data/java/enumValues.java") { cls -> val superTypes = cls.details(DocumentationNode.Kind.Supertype) assertEquals(0, superTypes.size()) @@ -193,7 +193,7 @@ public class JavaTest { } } - Test fun inheritorLinks() { + @Test fun inheritorLinks() { verifyPackageMember("test/data/java/inheritorLinks.java") { cls -> val fooClass = cls.members.single { it.name == "Foo" } val inheritors = fooClass.references(DocumentationReference.Kind.Inheritor) diff --git a/test/src/model/LinkTest.kt b/test/src/model/LinkTest.kt index 151d2696..a8004367 100644 --- a/test/src/model/LinkTest.kt +++ b/test/src/model/LinkTest.kt @@ -5,7 +5,7 @@ import kotlin.test.* import org.jetbrains.dokka.* public class LinkTest { - Test fun linkToSelf() { + @Test fun linkToSelf() { verifyModel("test/data/links/linkToSelf.kt") { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) @@ -15,7 +15,7 @@ public class LinkTest { } } - Test fun linkToMember() { + @Test fun linkToMember() { verifyModel("test/data/links/linkToMember.kt") { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) @@ -25,7 +25,7 @@ public class LinkTest { } } - Test fun linkToQualifiedMember() { + @Test fun linkToQualifiedMember() { verifyModel("test/data/links/linkToQualifiedMember.kt") { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) @@ -35,7 +35,7 @@ public class LinkTest { } } - Test fun linkToParam() { + @Test fun linkToParam() { verifyModel("test/data/links/linkToParam.kt") { model -> with(model.members.single().members.single()) { assertEquals("Foo", name) diff --git a/test/src/model/PackageTest.kt b/test/src/model/PackageTest.kt index 701efbf0..52324f1d 100644 --- a/test/src/model/PackageTest.kt +++ b/test/src/model/PackageTest.kt @@ -8,7 +8,7 @@ import kotlin.test.assertEquals import kotlin.test.assertTrue public class PackageTest { - Test fun rootPackage() { + @Test fun rootPackage() { verifyModel("test/data/packages/rootPackage.kt") { model -> with(model.members.single()) { assertEquals(DocumentationNode.Kind.Package, kind) @@ -21,7 +21,7 @@ public class PackageTest { } } - Test fun simpleNamePackage() { + @Test fun simpleNamePackage() { verifyModel("test/data/packages/simpleNamePackage.kt") { model -> with(model.members.single()) { assertEquals(DocumentationNode.Kind.Package, kind) @@ -34,7 +34,7 @@ public class PackageTest { } } - Test fun dottedNamePackage() { + @Test fun dottedNamePackage() { verifyModel("test/data/packages/dottedNamePackage.kt") { model -> with(model.members.single()) { assertEquals(DocumentationNode.Kind.Package, kind) @@ -47,7 +47,7 @@ public class PackageTest { } } - Test fun multipleFiles() { + @Test fun multipleFiles() { verifyModel(KotlinSourceRoot("test/data/packages/dottedNamePackage.kt"), KotlinSourceRoot("test/data/packages/simpleNamePackage.kt")) { model -> assertEquals(2, model.members.count()) @@ -69,7 +69,7 @@ public class PackageTest { } } - Test fun multipleFilesSamePackage() { + @Test fun multipleFilesSamePackage() { verifyModel(KotlinSourceRoot("test/data/packages/simpleNamePackage.kt"), KotlinSourceRoot("test/data/packages/simpleNamePackage2.kt")) { model -> assertEquals(1, model.members.count()) diff --git a/test/src/model/PropertyTest.kt b/test/src/model/PropertyTest.kt index 0853cbc5..0da510ed 100644 --- a/test/src/model/PropertyTest.kt +++ b/test/src/model/PropertyTest.kt @@ -8,7 +8,7 @@ import kotlin.test.assertEquals import kotlin.test.assertTrue public class PropertyTest { - Test fun valueProperty() { + @Test fun valueProperty() { verifyModel("test/data/properties/valueProperty.kt") { model -> with(model.members.single().members.single()) { assertEquals("property", name) @@ -21,7 +21,7 @@ public class PropertyTest { } } - Test fun variableProperty() { + @Test fun variableProperty() { verifyModel("test/data/properties/variableProperty.kt") { model -> with(model.members.single().members.single()) { assertEquals("property", name) @@ -34,7 +34,7 @@ public class PropertyTest { } } - Test fun valuePropertyWithGetter() { + @Test fun valuePropertyWithGetter() { verifyModel("test/data/properties/valuePropertyWithGetter.kt") { model -> with(model.members.single().members.single()) { assertEquals("property", name) @@ -47,7 +47,7 @@ public class PropertyTest { } } - Test fun variablePropertyWithAccessors() { + @Test fun variablePropertyWithAccessors() { verifyModel("test/data/properties/variablePropertyWithAccessors.kt") { model -> with(model.members.single().members.single()) { assertEquals("property", name) @@ -64,7 +64,7 @@ public class PropertyTest { } } - Test fun annotatedProperty() { + @Test fun annotatedProperty() { verifyModel("test/data/properties/annotatedProperty.kt") { model -> with(model.members.single().members.single()) { assertEquals(1, annotations.count()) @@ -77,7 +77,7 @@ public class PropertyTest { } } - Test fun propertyWithReceiver() { + @Test fun propertyWithReceiver() { verifyModel("test/data/properties/propertyWithReceiver.kt") { model -> with(model.members.single().members.single()) { assertEquals("String", name) @@ -90,7 +90,7 @@ public class PropertyTest { } } - Test fun propertyOverride() { + @Test fun propertyOverride() { verifyModel("test/data/properties/propertyOverride.kt") { model -> with(model.members.single().members.single { it.name == "Bar" }.members.single { it.name == "xyzzy"}) { assertEquals("xyzzy", name) |