Skip to content

Commit

Permalink
fix 🐛
Browse files Browse the repository at this point in the history
  • Loading branch information
siosio committed Oct 3, 2021
1 parent 2caac1e commit 51365da
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 23 deletions.
6 changes: 2 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

group 'siosio'
version '2.0.3'
version '2.0.4'

apply plugin: 'kotlin'

Expand All @@ -34,9 +34,7 @@ compileTestKotlin {
}
intellij {
plugins = ['Kotlin', 'java']
intellij.type = 'IC'
type = 'IC'
}

patchPluginXml {
}
patchPluginXml.sinceBuild = '202'
31 changes: 12 additions & 19 deletions src/main/kotlin/siosio/kodkod/KDocGenerator.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
package siosio.kodkod

import com.intellij.psi.*
import org.jetbrains.kotlin.idea.core.resolveType
import org.jetbrains.kotlin.idea.refactoring.fqName.fqName
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.types.KotlinType
import com.intellij.psi.PsiNameIdentifierOwner
import org.jetbrains.kotlin.idea.debugger.sequence.psi.resolveType
import org.jetbrains.kotlin.idea.refactoring.changeSignature.getDeclarationBody
import org.jetbrains.kotlin.nj2k.postProcessing.type
import org.jetbrains.kotlin.psi.KtClass
import org.jetbrains.kotlin.psi.KtNamedDeclarationUtil
import org.jetbrains.kotlin.psi.KtNamedFunction
import org.jetbrains.kotlin.psi.KtPsiUtil
import org.jetbrains.kotlin.types.typeUtil.isUnit

interface KDocGenerator {
Expand Down Expand Up @@ -34,19 +37,9 @@ class NamedFunctionKDocGenerator(private val function: KtNamedFunction) : KDocGe
if (function.valueParameters.isNotEmpty()) {
builder.appendLine(toParamsKdoc(params = function.valueParameters))
}
when (function.hasDeclaredReturnType()) {
true -> {
function.typeReference?.let {
if (it.text != "Unit") {
builder.appendLine("* @return")
}
}
}
false -> {
function.bodyExpression?.resolveType()?.let {
builder.appendLine("* @return")
}
}

if (function.type()?.isUnit() == false) {
builder.appendLine("* @return")
}
builder.appendLine("*/")
return builder.toString()
Expand Down Expand Up @@ -82,4 +75,4 @@ class ClassKDocGenerator(private val klass: KtClass) : KDocGenerator {
builder.appendLine("*/")
return builder.toString()
}
}
}

0 comments on commit 51365da

Please sign in to comment.