Skip to content

Commit

Permalink
fixed compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nulls committed Jun 28, 2022
1 parent a31d184 commit a9d6f3a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class KdocMethods(configRules: List<RulesConfig>) : DiktatRule(
// if no tag failed, we have too little information to suggest KDoc - it would just be empty
if (kdoc == null && anyTagFailed) {
addKdocTemplate(node, name, missingParameters, explicitlyThrownExceptions, returnCheckFailed)
} else if (kdoc == null && !isReferenceExpressionWithSameName(node, kdocTags)) {
} else if (kdoc == null && !isReferenceExpressionWithSameName(node)) {
MISSING_KDOC_ON_FUNCTION.warn(configRules, emitWarn, false, name, node.startOffset, node)
} else {
if (paramCheckFailed) {
Expand Down Expand Up @@ -149,7 +149,7 @@ class KdocMethods(configRules: List<RulesConfig>) : DiktatRule(
}
}

private fun isReferenceExpressionWithSameName(node: ASTNode, kdocTags: Collection<KDocTag>?): Boolean {
private fun isReferenceExpressionWithSameName(node: ASTNode): Boolean {
val lastDotQualifiedExpression = node.findChildByType(DOT_QUALIFIED_EXPRESSION)?.psi
?.let { (it as KtDotQualifiedExpression).selectorExpression?.text?.substringBefore('(') }
val funName = (node.psi as KtFunction).name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,13 +416,13 @@ class NewlinesRule(configRules: List<RulesConfig>) : DiktatRule(
val funNode = blockNode.treeParent
val returnType = (funNode.psi as? KtNamedFunction)?.typeReference?.node
val expression = node.findChildByType(RETURN_KEYWORD)!!.nextCodeSibling()!!
val blockNode = funNode.findChildByType(BLOCK)
val childBlockNode = funNode.findChildByType(BLOCK)
funNode.apply {
if (returnType != null) {
removeRange(returnType.treeNext, null)
addChild(PsiWhiteSpaceImpl(" "), null)
} else if (blockNode != null) {
removeChild(blockNode)
} else if (childBlockNode != null) {
removeChild(childBlockNode)
}
addChild(LeafPsiElement(EQ, "="), null)
addChild(PsiWhiteSpaceImpl(" "), null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ import org.jetbrains.kotlin.psi.KtCallExpression
import org.jetbrains.kotlin.psi.KtConstantExpression
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtIfExpression
import org.jetbrains.kotlin.psi.KtNameReferenceExpression
import org.jetbrains.kotlin.psi.KtProperty
import org.jetbrains.kotlin.psi.KtReferenceExpression
import org.jetbrains.kotlin.psi.KtStringTemplateExpression
import org.jetbrains.kotlin.psi.KtTryExpression
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import org.jetbrains.kotlin.psi.psiUtil.parents
Expand Down Expand Up @@ -53,9 +51,6 @@ fun KtExpression.containsOnlyConstants(): Boolean =
fun KtProperty.getDeclarationScope() =
// FixMe: class body is missing here
getParentOfType<KtBlockExpression>(true)
.let { if (it is KtIfExpression) it.then!! else it }
.let { if (it is KtTryExpression) it.tryBlock else it }
as KtBlockExpression?

/**
* Method that tries to find a local property declaration with the same name as current [KtNameReferenceExpression] element
Expand Down

0 comments on commit a9d6f3a

Please sign in to comment.