Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Intellij Community
Commits
fb749f2a
Commit
fb749f2a
authored
7 years ago
by
Pavel Dolgov
Browse files
Options
Download
Email Patches
Plain Diff
Generate module-info: Use UniqueNameGenerator for module-info names (IDEA-184148)
parent
a20a4f5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/java-impl/src/com/intellij/codeInspection/java19api/Java9GenerateModuleDescriptorsAction.java
+6
-12
...ction/java19api/Java9GenerateModuleDescriptorsAction.java
with
6 additions
and
12 deletions
+6
-12
java/java-impl/src/com/intellij/codeInspection/java19api/Java9GenerateModuleDescriptorsAction.java
+
6
-
12
View file @
fb749f2a
...
...
@@ -42,7 +42,7 @@ import com.intellij.psi.search.GlobalSearchScope;
import
com.intellij.psi.search.ProjectScope
;
import
com.intellij.refactoring.RefactoringBundle
;
import
com.intellij.refactoring.util.CommonRefactoringUtil
;
import
com.intellij.util.
containers.ObjectIntHashMap
;
import
com.intellij.util.
text.UniqueNameGenerator
;
import
gnu.trove.THashMap
;
import
gnu.trove.THashSet
;
import
one.util.streamex.StreamEx
;
...
...
@@ -568,7 +568,7 @@ public class Java9GenerateModuleDescriptorsAction extends AnAction {
}
private
static
class
UniqueModuleNames
{
private
final
ObjectIntHashMap
<
String
>
myCounts
=
new
ObjectIntHashMap
<>()
;
private
final
UniqueNameGenerator
myNameGenerator
;
public
UniqueModuleNames
(
@NotNull
Project
project
)
{
LOG
.
assertTrue
(!
DumbService
.
isDumb
(
project
),
"Module name index should be ready"
);
...
...
@@ -576,23 +576,17 @@ public class Java9GenerateModuleDescriptorsAction extends AnAction {
JavaModuleNameIndex
index
=
JavaModuleNameIndex
.
getInstance
();
GlobalSearchScope
scope
=
ProjectScope
.
getAllScope
(
project
);
List
<
PsiJavaModule
>
modules
=
new
ArrayList
<>();
for
(
String
key
:
index
.
getAllKeys
(
project
))
{
for
(
PsiJavaModule
module
:
index
.
get
(
key
,
project
,
scope
))
{
String
name
=
ReadAction
.
compute
(()
->
module
.
getName
());
myCounts
.
put
(
name
,
1
);
}
modules
.
addAll
(
index
.
get
(
key
,
project
,
scope
));
}
myNameGenerator
=
new
UniqueNameGenerator
(
modules
,
module
->
ReadAction
.
compute
(()
->
module
.
getName
()));
}
@NotNull
public
String
getUniqueName
(
@NotNull
Module
module
)
{
String
name
=
NameConverter
.
convertModuleName
(
module
.
getName
());
int
count
=
myCounts
.
get
(
name
,
0
);
myCounts
.
put
(
name
,
count
+
1
);
if
(
count
!=
0
)
{
name
+=
count
;
}
return
name
;
return
myNameGenerator
.
generateUniqueName
(
name
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help