Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Temporary removing K2 compiler Frontend #1405

Merged
merged 4 commits into from
Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
nulls marked this conversation as resolved.
Show resolved Hide resolved
<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 }
nulls marked this conversation as resolved.
Show resolved Hide resolved
.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