2

IntelliJ 添加了太多的版权标头

我将 IntelliJ 设置为在源代码中包含许可证作为标题中的注释。由于某种原因,IntelliJ 在所有文件中重复了几个版权声明。

因此,目前所有文件都有一到五个(或更多)重复的许可证标头,例如:

/*
 * Copyright [2014] [John Doe]
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

/*
 * Copyright [2014] [John Doe]
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or    implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

如何删除同一标题的多次重复?

我找不到再次删除标题的功能。IntelliJ 是否提供这样的功能?我应该使用 Linux 板工具并替换 tne 字符串吗?我怎样才能安全地做到这一点?

4

3 回答 3

2

根据Creating Copyright Profiles - IntelliJ IDEA 13.1.0 Web Help(粗体字是我的):

在“检测评论版权的关键字”文本框中,键入字符串以在版权更新期间将版权声明与其他评论区分开来。

即,它必须是一个足够独特的子字符串,以可靠地识别您在版权配置文件中指定的版权声明。

于 2015-02-25T13:05:46.790 回答
0

您可以使用与设置它们相同的方法删除重复项。

请按照以下步骤操作:

  • 在设置中打开自定义配置文件。
  • 将用于检测版权的正则表达式设置为版权
  • 将“允许替换版权...”字段设置为您当前版权中重复的内容,例如您的示例中的John Doe

这将用单一版权替换所有重复项。调整它直到匹配。

于 2016-12-13T00:32:49.313 回答
-3

需要从源文件中删除版权声明和许可的情况极为罕见,因此编辑器/IDE 不太可能提供一键完成此操作的功能。

如果版权声明/许可相同,则您可以安全地删除除其中一个之外的所有内容。
如果您是版权所有者,那么您可以删除所有这些通知。

要删除它们,只需选择文本并将其删除。

于 2015-02-20T12:07:54.320 回答