Copy: Improve file copying
- Do not copy individual declarations if entire file is selected (keeping original content with comments, formatting, etc.) - Update package directive when original file packages matches its directory #KT-20092 Fixed #KT-18196 Fixed
This commit is contained in:
@@ -76,8 +76,18 @@ open class KtFile(viewProvider: FileViewProvider, val isCompiled: Boolean) :
|
||||
return if (ast != null) ast.psi as KtPackageDirective else null
|
||||
}
|
||||
|
||||
val packageFqName: FqName
|
||||
var packageFqName: FqName
|
||||
get() = stub?.getPackageFqName() ?: packageFqNameByTree
|
||||
set(value) {
|
||||
val packageDirective = packageDirective
|
||||
if (packageDirective != null) {
|
||||
packageDirective.fqName = value
|
||||
}
|
||||
else {
|
||||
val newPackageDirective = KtPsiFactory(this).createPackageDirectiveIfNeeded(value) ?: return
|
||||
addAfter(newPackageDirective, null)
|
||||
}
|
||||
}
|
||||
|
||||
val packageFqNameByTree: FqName
|
||||
get() = packageDirectiveByTree?.fqName ?: FqName.ROOT
|
||||
|
||||
Reference in New Issue
Block a user