Avoid creation expressions by texts

This commit is contained in:
Valentin Kipyatkov
2015-05-11 17:51:36 +03:00
parent 749416434f
commit 8a30d2d664
5 changed files with 22 additions and 19 deletions
@@ -121,7 +121,13 @@ public fun JetClassOrObject.effectiveDeclarations(): List<JetDeclaration> =
public fun JetClass.isAbstract(): Boolean = isInterface() || hasModifier(JetTokens.ABSTRACT_KEYWORD)
[suppress("UNCHECKED_CAST")]
public fun <T: PsiElement> PsiElement.replaced(newElement: T): T = replace(newElement) as T
public inline fun <reified T: PsiElement> PsiElement.replaced(newElement: T): T {
val result = replace(newElement)
return if (result is T)
result
else
(result as JetParenthesizedExpression).getExpression() as T
}
[suppress("UNCHECKED_CAST")]
public fun <T: PsiElement> T.copied(): T = copy() as T