Skip to content

Commit

Permalink
Temporary removing K2 compiler Frontend (#1405)
Browse files Browse the repository at this point in the history
### What's done:
- removed -Xuse-k2 option

Co-authored-by: Nariman Abdullin <[email protected]>
  • Loading branch information
orchestr7 and nulls authored Jun 28, 2022
1 parent 5f77cad commit f4709a6
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 22 deletions.
5 changes: 0 additions & 5 deletions diktat-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -138,11 +138,6 @@
</configuration>
</execution>
</executions>
<configuration>
<args>
<arg>-Xuse-k2</arg>
</args>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
6 changes: 0 additions & 6 deletions diktat-rules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,6 @@
</configuration>
</execution>
</executions>
<configuration>
<args>
<arg>-Xinline-classes</arg>
<arg>-Xuse-k2</arg>
</args>
</configuration>
</plugin>

<plugin>
Expand Down
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 @@ -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<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 f4709a6

Please sign in to comment.