From f822c51af0ca775a260f8aab010c9ccc9be8d52e Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Wed, 22 Jul 2015 20:00:50 +0300 Subject: Upgrade to latest kotlin --- dokka-fatjar/build.gradle | 2 ++ lib/kotlin-for-upsource.jar | Bin 13795854 -> 14136706 bytes src/Kotlin/DocumentationBuilder.kt | 26 +++++++++++++++----------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/dokka-fatjar/build.gradle b/dokka-fatjar/build.gradle index e7c9cd97..ffec3b82 100644 --- a/dokka-fatjar/build.gradle +++ b/dokka-fatjar/build.gradle @@ -30,6 +30,7 @@ jar { exclude 'META-INF/*.SF' exclude 'META-INF/*.DSA' exclude 'META-INF/*.RSA' + exclude '**/*.kt' } } from (zipTree(project.file('../out/dokka.jar'))) { @@ -37,6 +38,7 @@ jar { exclude 'META-INF/*.SF' exclude 'META-INF/*.DSA' exclude 'META-INF/*.RSA' + exclude '**/*.kt' } } diff --git a/lib/kotlin-for-upsource.jar b/lib/kotlin-for-upsource.jar index 78096350..e48549d3 100644 Binary files a/lib/kotlin-for-upsource.jar and b/lib/kotlin-for-upsource.jar differ diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index bea2f6fa..6c0b7b03 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.JetParameter import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant +import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.source.PsiSourceElement import org.jetbrains.kotlin.resolve.source.getPsi @@ -685,7 +686,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, val node = DocumentationNode(annotationClass.getName().asString(), Content.Empty, DocumentationNode.Kind.Annotation) val arguments = getAllValueArguments().toList().sortBy { it.first.getIndex() } arguments.forEach { - val valueNode = it.second.build() + val valueNode = it.second.value.toDocumentationNode() if (valueNode != null) { val paramNode = DocumentationNode(it.first.getName().asString(), Content.Empty, DocumentationNode.Kind.Parameter) paramNode.append(valueNode, DocumentationReference.Kind.Detail) @@ -695,15 +696,18 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, return node } - fun CompileTimeConstant.build(): DocumentationNode? { - val value = getValue() - val valueString = when(value) { - is String -> - "\"" + StringUtil.escapeStringCharacters(value) + "\"" - is EnumEntrySyntheticClassDescriptor -> - value.getContainingDeclaration().getName().asString() + "." + value.getName() - else -> value?.toString() - } - return if (valueString != null) DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value) else null + fun CompileTimeConstant.build(): DocumentationNode? { + val value: Any? = if (this is TypedCompileTimeConstant) getValue(type) else null + return value.toDocumentationNode() + } + + private fun Any?.toDocumentationNode(): DocumentationNode? = when (this) { + is String -> + "\"" + StringUtil.escapeStringCharacters(this) + "\"" + is EnumEntrySyntheticClassDescriptor -> + getContainingDeclaration().getName().asString() + "." + getName() + else -> this?.toString() + }.let { valueString -> + if (valueString != null) DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value) else null } } -- cgit From 891cdbbe19580ee2379e3b7cfe269109bf897d84 Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Fri, 24 Jul 2015 15:35:22 +0300 Subject: Put source position information to node's details section --- src/Languages/JavaLanguageService.kt | 4 ++-- src/Model/DocumentationNode.kt | 1 + src/Model/SourceLinks.kt | 24 ++++++++++++++++-------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/Languages/JavaLanguageService.kt b/src/Languages/JavaLanguageService.kt index 7446b34f..e491d1bd 100644 --- a/src/Languages/JavaLanguageService.kt +++ b/src/Languages/JavaLanguageService.kt @@ -123,9 +123,9 @@ public class JavaLanguageService : LanguageService { val receiver = node.details(Kind.Receiver).singleOrNull() append("(") if (receiver != null) - append((listOf(receiver) + node.details(Kind.Parameter)).map { renderParameter(it) }.join()) + (listOf(receiver) + node.details(Kind.Parameter)).map { renderParameter(it) }.joinTo(this) else - append(node.details(Kind.Parameter).map { renderParameter(it) }.join()) + node.details(Kind.Parameter).map { renderParameter(it) }.joinTo(this) append(")") }.toString() diff --git a/src/Model/DocumentationNode.kt b/src/Model/DocumentationNode.kt index 7f862183..2f0638bc 100644 --- a/src/Model/DocumentationNode.kt +++ b/src/Model/DocumentationNode.kt @@ -101,6 +101,7 @@ public open class DocumentationNode(val name: String, Value, SourceUrl, + SourcePosition, /** * A note which is rendered once on a page documenting a group of overloaded functions. diff --git a/src/Model/SourceLinks.kt b/src/Model/SourceLinks.kt index fc3293f2..dff4b36b 100644 --- a/src/Model/SourceLinks.kt +++ b/src/Model/SourceLinks.kt @@ -4,16 +4,15 @@ import com.intellij.psi.PsiElement import java.io.File import com.intellij.psi.PsiDocumentManager import com.intellij.psi.PsiNameIdentifierOwner +import org.jetbrains.kotlin.psi.psiUtil.startOffset class SourceLinkDefinition(val path: String, val url: String, val lineSuffix: String?) fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List) { - val path = psi?.getContainingFile()?.getVirtualFile()?.getPath() - if (path == null) { - return - } - val target = if (psi is PsiNameIdentifierOwner) psi.getNameIdentifier() else psi - val absPath = File(path).getAbsolutePath() + val path = psi?.containingFile?.virtualFile?.path ?: return + + val target = if (psi is PsiNameIdentifierOwner) psi.nameIdentifier else psi + val absPath = File(path).absolutePath val linkDef = sourceLinks.firstOrNull { absPath.startsWith(it.path) } if (linkDef != null) { var url = linkDef.url + path.substring(linkDef.path.length()) @@ -26,10 +25,19 @@ fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List Date: Fri, 24 Jul 2015 16:39:02 +0300 Subject: Rework toDocumentationNode function to use ConstantValue<*> instead of any? --- src/Kotlin/DocumentationBuilder.kt | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Kotlin/DocumentationBuilder.kt b/src/Kotlin/DocumentationBuilder.kt index 6c0b7b03..eda69841 100644 --- a/src/Kotlin/DocumentationBuilder.kt +++ b/src/Kotlin/DocumentationBuilder.kt @@ -18,6 +18,7 @@ import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.psi.JetParameter import org.jetbrains.kotlin.resolve.DescriptorUtils import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant +import org.jetbrains.kotlin.resolve.constants.ConstantValue import org.jetbrains.kotlin.resolve.constants.TypedCompileTimeConstant import org.jetbrains.kotlin.resolve.lazy.ResolveSession import org.jetbrains.kotlin.resolve.source.PsiSourceElement @@ -686,7 +687,7 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, val node = DocumentationNode(annotationClass.getName().asString(), Content.Empty, DocumentationNode.Kind.Annotation) val arguments = getAllValueArguments().toList().sortBy { it.first.getIndex() } arguments.forEach { - val valueNode = it.second.value.toDocumentationNode() + val valueNode = it.second.toDocumentationNode() if (valueNode != null) { val paramNode = DocumentationNode(it.first.getName().asString(), Content.Empty, DocumentationNode.Kind.Parameter) paramNode.append(valueNode, DocumentationReference.Kind.Detail) @@ -696,18 +697,20 @@ class DocumentationBuilder(val resolutionFacade: ResolutionFacade, return node } - fun CompileTimeConstant.build(): DocumentationNode? { - val value: Any? = if (this is TypedCompileTimeConstant) getValue(type) else null - return value.toDocumentationNode() + fun CompileTimeConstant.build(): DocumentationNode? = when (this) { + is TypedCompileTimeConstant -> constantValue.toDocumentationNode() + else -> null } - private fun Any?.toDocumentationNode(): DocumentationNode? = when (this) { - is String -> - "\"" + StringUtil.escapeStringCharacters(this) + "\"" - is EnumEntrySyntheticClassDescriptor -> - getContainingDeclaration().getName().asString() + "." + getName() - else -> this?.toString() - }.let { valueString -> - if (valueString != null) DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value) else null + fun ConstantValue<*>.toDocumentationNode(): DocumentationNode? = value?.let { value -> + when (value) { + is String -> + "\"" + StringUtil.escapeStringCharacters(value) + "\"" + is EnumEntrySyntheticClassDescriptor -> + value.containingDeclaration.name.asString() + "." + value.name.asString() + else -> value.toString() + }.let { valueString -> + DocumentationNode(valueString, Content.Empty, DocumentationNode.Kind.Value) + } } } -- cgit From 28685c67cff2ea5e2f11152c98fa732fc205f0d4 Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Mon, 27 Jul 2015 14:56:53 +0300 Subject: SourcePosition shouldn't contain nulls --- src/Model/SourceLinks.kt | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/Model/SourceLinks.kt b/src/Model/SourceLinks.kt index dff4b36b..4530518f 100644 --- a/src/Model/SourceLinks.kt +++ b/src/Model/SourceLinks.kt @@ -26,7 +26,21 @@ fun DocumentationNode.appendSourceLink(psi: PsiElement?, sourceLinks: List path + columnNumber == null -> "$path:$lineNumber" + else -> "$path:$lineNumber:$columnNumber" + } } fun PsiElement.lineNumber(): Int? { -- cgit From 2930cd9685c5e6296b24e9530b296c7ce3ea89fa Mon Sep 17 00:00:00 2001 From: Sergey Mashkov Date: Mon, 27 Jul 2015 16:11:36 +0300 Subject: Upgrade markdown.jar --- lib/markdown.jar | Bin 239956 -> 239909 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/lib/markdown.jar b/lib/markdown.jar index 4ca022d5..9765d80a 100644 Binary files a/lib/markdown.jar and b/lib/markdown.jar differ -- cgit