Eclipse有一个非常有用的功能:检测类的包声明与其实际的源树路径不一致。 然后Eclipse会
建议重命名包声明
或者,建议将类移动到与包声明对应的源路径。
然后立即执行IDE用户同意的任一操作。
Intellij中是否有一个机制可以触发此建议并执行类包声明的功能?
Eclipse has a rather helpful feature: detect that the package declaration of a class is not in conjunction with its actual source tree path. Eclipse would then
Suggest renaming package declaration
Or, suggest moving the class to the source path that corresponds to the package declaration.
And then promptly perform either of the actions as agreed by the IDE user.
Is there a mechanism in Intellij that would trigger this suggestion and perform feature for the class package declaration?
最满意答案
当类未被命名为.java文件但包声明正确时,Intellij会在类名称上标记错误。 只需将光标移动到类名称,然后按Alt + Enter。
如果类正确命名但包声明不正确,则Intellij会在包声明中标记错误。 只需将光标移动到包声明,然后按Alt + Enter。
When the class is not named as the .java File but the package declaration is correct, Intellij marks an error at the class name. Simply move the cursor to the class name and hit Alt+Enter.
When the class is correctly named but the package declaration is incorrect, Intellij marks an error at the package declaration. Simply move the cursor to the package declaration and hit Alt+Enter.
更多推荐
发布评论