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:
Alexey Sedunov
2017-09-19 15:21:31 +03:00
parent fbf6bd534c
commit 0beadddb7f
22 changed files with 159 additions and 13 deletions
@@ -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