Dot not lengthen references to declarations contained in the moving element
This commit is contained in:
+3
-1
@@ -108,12 +108,14 @@ public class MoveKotlinFileHandler : MoveFileHandler() {
|
||||
val project = psiFile.getProject()
|
||||
val newPackageName = newParent.getPackage()?.getQualifiedName() ?: ""
|
||||
|
||||
val searchScope = GlobalSearchScope.projectScope(project) intersectWith
|
||||
GlobalSearchScope.notScope(GlobalSearchScope.fileScope(psiFile))
|
||||
return psiFile.getDeclarations().flatMap { declaration ->
|
||||
val name = (declaration as? JetNamedDeclaration)?.getName()
|
||||
if (name != null) {
|
||||
val newFqName = StringUtil.getQualifiedName(newPackageName, name)!!
|
||||
|
||||
val results = ReferencesSearch.search(declaration, GlobalSearchScope.projectScope(project), false)
|
||||
val results = ReferencesSearch.search(declaration, searchScope, false)
|
||||
.toSet()
|
||||
.mapTo(ArrayList<UsageInfo?>()) { ref ->
|
||||
val range = ref.getRangeInElement()!!
|
||||
|
||||
@@ -33,6 +33,9 @@ import org.jetbrains.jet.plugin.JetFileType
|
||||
import org.jetbrains.jet.lang.psi.JetClassOrObject
|
||||
import org.jetbrains.jet.lang.psi.JetNamedDeclaration
|
||||
import org.jetbrains.jet.plugin.imports.canBeReferencedViaImport
|
||||
import org.jetbrains.jet.plugin.codeInsight.DescriptorToDeclarationUtil
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.isInsideOf
|
||||
import org.jetbrains.jet.lang.psi.psiUtil.isAncestor
|
||||
|
||||
public class PackageNameInfo(val oldPackageName: FqName, val newPackageName: FqName)
|
||||
|
||||
@@ -52,6 +55,9 @@ public fun JetElement.updateInternalReferencesOnPackageNameChange(
|
||||
}
|
||||
if (descriptor == null || !descriptor.canBeReferencedViaImport()) continue
|
||||
|
||||
val declaration = DescriptorToDeclarationUtil.getDeclaration(file, descriptor, bindingContext)
|
||||
if (declaration == null || isAncestor(declaration, true)) continue
|
||||
|
||||
val packageName = DescriptorUtils.getParentOfType(
|
||||
descriptor, javaClass<PackageFragmentDescriptor>(), false
|
||||
)?.let { DescriptorUtils.getFqName(it).toSafe() }
|
||||
|
||||
Reference in New Issue
Block a user