Change semantics of getObjectKeyword() function

This commit is contained in:
Yan Zhulanow
2016-03-31 19:55:54 +03:00
parent 41979de71e
commit 726bfca540
5 changed files with 11 additions and 11 deletions
@@ -51,7 +51,7 @@ object PositioningStrategies {
when (element) {
is KtObjectLiteralExpression -> {
val objectDeclaration = element.objectDeclaration
val objectKeyword = objectDeclaration.getObjectKeyword()
val objectKeyword = objectDeclaration.getObjectKeyword()!!
val delegationSpecifierList = objectDeclaration.getSuperTypeList()
if (delegationSpecifierList == null) {
return markElement(objectKeyword)
@@ -60,8 +60,8 @@ object PositioningStrategies {
}
is KtObjectDeclaration -> {
return markRange(
element.getObjectKeyword(),
element.getNameIdentifier() ?: element.getObjectKeyword()
element.getObjectKeyword()!!,
element.getNameIdentifier() ?: element.getObjectKeyword()!!
)
}
is KtConstructorDelegationCall -> {
@@ -265,7 +265,7 @@ object PositioningStrategies {
}
val elementToMark = when (element) {
is KtObjectDeclaration -> element.getObjectKeyword()
is KtObjectDeclaration -> element.getObjectKeyword()!!
is KtPropertyAccessor -> element.getNamePlaceholder()
is KtAnonymousInitializer -> element
else -> throw IllegalArgumentException(
@@ -45,8 +45,8 @@ class KtObjectDeclaration : KtClassOrObject {
override fun setName(@NonNls name: String): PsiElement {
if (nameIdentifier == null) {
val psiFactory = KtPsiFactory(project)
val result = addAfter(psiFactory.createIdentifier(name), getObjectKeyword())
addAfter(psiFactory.createWhiteSpace(), getObjectKeyword())
val result = addAfter(psiFactory.createIdentifier(name), getObjectKeyword()!!)
addAfter(psiFactory.createWhiteSpace(), getObjectKeyword()!!)
return result
}
@@ -58,7 +58,7 @@ class KtObjectDeclaration : KtClassOrObject {
fun isCompanion(): Boolean = _stub?.isCompanion() ?: hasModifier(KtTokens.COMPANION_KEYWORD)
override fun getTextOffset(): Int = nameIdentifier?.textRange?.startOffset
?: getObjectKeyword().textRange.startOffset
?: getObjectKeyword()!!.textRange.startOffset
override fun <R, D> accept(visitor: KtVisitor<R, D>, data: D): R {
return visitor.visitObjectDeclaration(this, data)
@@ -66,5 +66,5 @@ class KtObjectDeclaration : KtClassOrObject {
fun isObjectLiteral(): Boolean = _stub?.isObjectLiteral() ?: (parent is KtObjectLiteralExpression)
fun getObjectKeyword(): PsiElement = findChildByType(KtTokens.OBJECT_KEYWORD)!!
fun getObjectKeyword(): PsiElement? = findChildByType(KtTokens.OBJECT_KEYWORD)
}