如何在IntelliJ中修复软件包名称? [英] How to fix package names in IntelliJ?

查看:114
本文介绍了如何在IntelliJ中修复软件包名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以修复IntelliJ中给定文件夹中的所有包名?

Is it possible to fix all the package names in a given folder in IntelliJ?

如果文件被手动导入IntelliJ,并且它们的包名都错了(包括子文件夹),我如何大规模修复包名?

If files are manually imported into IntelliJ, and their package names are all wrong (including the sub-folders), how can I mass fix the package names?

到目前为止,这给我带来了很多悲痛....

This has caused me a lot of grief so far....

转移到包裹或重命名包裹

这必须是一个错误。

示例:

如果我在项目资源管理器中的软件包上,并重命名该软件包,请说:

If I am on a package in the project explorer, and rename the package, say it is:

com.example.xml.xml

现在我想将此(及其下的所有文件)更改为:

Now I want to change this (and all the files under it) to:

com.example.xml

我似乎无法做到!

当它说将包com.example.xml.xml重命名为时:

When it says "rename package com.example.xml.xml to":

如果我输入 com.example.xml它不起作用。我不确定它是怎么回事,我花了一个多小时尝试这个,因为我有更多文件要导入/修复。

If I enter "com.example.xml" it won't work. I'm not sure what it is going on, I have spent a over an hour trying this as I have more files to import/fix.

推荐答案

看来你不能像这样更改一个完整的包名:com.example.xml.xml,但你可以更改每个片段,为此你可以去查看选项(一点点)在项目视图中,禁用紧凑的空中间包选项,并执行类似于从末尾重命名第二个xml的操作,因此最终包可能会出现类似:

It seems you can't change a full package name like this one: "com.example.xml.xml", but you can change each fragment, for that you can go to "View Options" (a little wheel) in the project view, disable "compact empty middle packages" options, and do something like renaming the second "xml" from the end, so the final package could get into something like:

com
 -example
   -bar
     -xml

然后你可以将最后一个xml中的所有内容拖放到bar包中,最后删除最后一个xml。在你的情况下,似乎你不需要重命名包只需移动内容

Then you can drag and drop all contents in the last "xml" to "bar" package and finally delete the last "xml". In your case it seems you won't need to rename the package just move the contents

这篇关于如何在IntelliJ中修复软件包名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆