From f4709a6d6e86cf76d922e02c5d00b886dcb268b4 Mon Sep 17 00:00:00 2001 From: Andrey Kuleshov Date: Tue, 28 Jun 2022 19:29:26 +0300 Subject: [PATCH] Temporary removing K2 compiler Frontend (#1405) ### What's done: - removed -Xuse-k2 option Co-authored-by: Nariman Abdullin --- diktat-maven-plugin/pom.xml | 5 ----- diktat-rules/pom.xml | 6 ------ .../cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt | 4 ++-- .../diktat/ruleset/rules/chapter3/files/NewlinesRule.kt | 6 +++--- .../main/kotlin/org/cqfn/diktat/ruleset/utils/PsiUtils.kt | 6 ------ 5 files changed, 5 insertions(+), 22 deletions(-) diff --git a/diktat-maven-plugin/pom.xml b/diktat-maven-plugin/pom.xml index beba269851..055cb424da 100644 --- a/diktat-maven-plugin/pom.xml +++ b/diktat-maven-plugin/pom.xml @@ -138,11 +138,6 @@ - - - -Xuse-k2 - - org.apache.maven.plugins diff --git a/diktat-rules/pom.xml b/diktat-rules/pom.xml index c19b5e5505..9f9b56c8c3 100644 --- a/diktat-rules/pom.xml +++ b/diktat-rules/pom.xml @@ -135,12 +135,6 @@ - - - -Xinline-classes - -Xuse-k2 - - diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt index 2f22e8f909..e9080d8b86 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter2/kdoc/KdocMethods.kt @@ -121,7 +121,7 @@ class KdocMethods(configRules: List) : 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) { @@ -149,7 +149,7 @@ class KdocMethods(configRules: List) : DiktatRule( } } - private fun isReferenceExpressionWithSameName(node: ASTNode, kdocTags: Collection?): 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 diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt index 44237ad89b..14cd33672e 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/rules/chapter3/files/NewlinesRule.kt @@ -416,13 +416,13 @@ class NewlinesRule(configRules: List) : 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) diff --git a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/PsiUtils.kt b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/PsiUtils.kt index af4e91220a..71bb91331f 100644 --- a/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/PsiUtils.kt +++ b/diktat-rules/src/main/kotlin/org/cqfn/diktat/ruleset/utils/PsiUtils.kt @@ -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 @@ -49,13 +47,9 @@ fun KtExpression.containsOnlyConstants(): Boolean = * Here we assume that property can be declared only in block, since declaration is not an expression in kotlin * and compiler prohibits things like `if (condition) val x = 0`. */ -@Suppress("UnsafeCallOnNullableType") fun KtProperty.getDeclarationScope() = // FixMe: class body is missing here getParentOfType(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