Getting rid of confusing methods on PsiElement's

This commit is contained in:
Valentin Kipyatkov
2015-05-28 23:16:28 +03:00
parent e99b343be3
commit 006c02b569
4 changed files with 7 additions and 8 deletions
@@ -129,7 +129,7 @@ public fun JetDeclaration.isOverridable(): Boolean {
hasModifier(JetTokens.ABSTRACT_KEYWORD) || hasModifier(JetTokens.OPEN_KEYWORD) || hasModifier(JetTokens.OVERRIDE_KEYWORD)
}
public fun PsiElement.isExtensionDeclaration(): Boolean {
public fun JetDeclaration.isExtensionDeclaration(): Boolean {
val callable: JetCallableDeclaration? = when (this) {
is JetNamedFunction, is JetProperty -> this as JetCallableDeclaration
is JetPropertyAccessor -> getNonStrictParentOfType<JetProperty>()
@@ -139,7 +139,7 @@ public fun PsiElement.isExtensionDeclaration(): Boolean {
return callable?.getReceiverTypeReference() != null
}
public fun PsiElement.isObjectLiteral(): Boolean = this is JetObjectDeclaration && isObjectLiteral()
public fun JetClassOrObject.isObjectLiteral(): Boolean = this is JetObjectDeclaration && isObjectLiteral()
//TODO: git rid of this method
public fun PsiElement.deleteElementAndCleanParent() {
@@ -70,7 +70,7 @@ public fun JetParameter.toPsiParameter(): PsiParameter? {
val paramIndex = paramList.getParameters().indexOf(this)
val owner = paramList.getParent()
val lightParamIndex = if (owner != null && owner.isExtensionDeclaration()) paramIndex + 1 else paramIndex
val lightParamIndex = if (owner is JetDeclaration && owner.isExtensionDeclaration()) paramIndex + 1 else paramIndex
val method: PsiMethod? = when (owner) {
is JetFunction -> LightClassUtil.getLightClassMethod(owner)