Rename heared/impl around highlighter markers
This commit is contained in:
committed by
Mikhail Glukhikh
parent
8d8f683042
commit
88644001d3
@@ -968,9 +968,9 @@ fun KtNamedDeclaration.isCompanionMemberOf(klass: KtClassOrObject): Boolean {
|
||||
}
|
||||
|
||||
internal fun KtDeclaration.withExpectedActuals(): List<KtDeclaration> {
|
||||
val header = liftToExpected() ?: return listOf(this)
|
||||
val implementations = header.actualsForExpected()
|
||||
return listOf(header) + implementations
|
||||
val expect = liftToExpected() ?: return listOf(this)
|
||||
val actuals = expect.actualsForExpected()
|
||||
return listOf(expect) + actuals
|
||||
}
|
||||
|
||||
internal fun KtDeclaration.resolveToExpectedDescriptorIfPossible(): DeclarationDescriptor {
|
||||
|
||||
+3
-3
@@ -108,10 +108,10 @@ class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() {
|
||||
get() = originalDeclaration
|
||||
}
|
||||
|
||||
private fun substituteForHeaderOrImpl(element: PsiElement?) = (element?.namedUnwrappedElement as? KtNamedDeclaration)?.liftToExpected()
|
||||
private fun substituteForExpectOrActual(element: PsiElement?) = (element?.namedUnwrappedElement as? KtNamedDeclaration)?.liftToExpected()
|
||||
|
||||
override fun substituteElementToRename(element: PsiElement?, editor: Editor?): PsiElement? {
|
||||
substituteForHeaderOrImpl(element)?.let { return it }
|
||||
substituteForExpectOrActual(element)?.let { return it }
|
||||
|
||||
val wrappedMethod = wrapPsiMethod(element) ?: return element
|
||||
|
||||
@@ -145,7 +145,7 @@ class RenameKotlinFunctionProcessor : RenameKotlinPsiProcessor() {
|
||||
renameCallback.pass(elementToProcess)
|
||||
}
|
||||
|
||||
substituteForHeaderOrImpl(element)?.let { return preprocessAndPass(it) }
|
||||
substituteForExpectOrActual(element)?.let { return preprocessAndPass(it) }
|
||||
|
||||
val wrappedMethod = wrapPsiMethod(element) ?: return
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@ abstract class RenameKotlinPsiProcessor : RenamePsiElementProcessor() {
|
||||
|
||||
val declaration = element.namedUnwrappedElement as? KtNamedDeclaration
|
||||
if (declaration != null) {
|
||||
declaration.liftToExpected()?.let { headerDeclaration ->
|
||||
allRenames[headerDeclaration] = safeNewName
|
||||
headerDeclaration.actualsForExpected().forEach { allRenames[it] = safeNewName }
|
||||
declaration.liftToExpected()?.let { expectDeclaration ->
|
||||
allRenames[expectDeclaration] = safeNewName
|
||||
expectDeclaration.actualsForExpected().forEach { allRenames[it] = safeNewName }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -417,10 +417,10 @@ class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
): Collection<PsiElement>? {
|
||||
when (element) {
|
||||
is KtParameter -> {
|
||||
val headerParameter = element.liftToExpected() as? KtParameter
|
||||
if (headerParameter != null && headerParameter != element) {
|
||||
val expectParameter = element.liftToExpected() as? KtParameter
|
||||
if (expectParameter != null && expectParameter != element) {
|
||||
if (shouldAllowPropagationToExpected(element)) {
|
||||
return listOf(headerParameter)
|
||||
return listOf(expectParameter)
|
||||
} else {
|
||||
element.ownerFunction?.dropActualModifier = true
|
||||
return listOf(element)
|
||||
|
||||
Reference in New Issue
Block a user