-
Notifications
You must be signed in to change notification settings - Fork 5.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Only process each buildscript once in JavaGradleProjectResolver #2983
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,9 @@ | |
@Order(ExternalSystemConstants.UNORDERED) | ||
public final class JavaGradleProjectResolver extends AbstractProjectResolverExtension { | ||
|
||
private final IdentityHashMap<GradleBuildScriptClasspathModel, List<BuildScriptClasspathData.ClasspathEntry>> buildScriptEntriesMap = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Storing state here will cause memory leak, as this class is a long-living service. It is not re-created on each sync. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will apply your suggestion from the other PR here too. |
||
new IdentityHashMap<>(); | ||
|
||
@Override | ||
public void populateProjectExtraModels(@NotNull IdeaProject gradleProject, @NotNull DataNode<ProjectData> ideProject) { | ||
populateJavaProjectCompilerSettings(gradleProject, ideProject); | ||
|
@@ -149,10 +152,10 @@ private void populateBuildScriptClasspathData(@NotNull IdeaModule gradleModule, | |
buildScriptClasspathModel = resolverCtx.getExtraProject(gradleModule, GradleBuildScriptClasspathModel.class); | ||
final List<BuildScriptClasspathData.ClasspathEntry> classpathEntries; | ||
if (buildScriptClasspathModel != null) { | ||
classpathEntries = ContainerUtil.map( | ||
classpathEntries = buildScriptEntriesMap.computeIfAbsent(buildScriptClasspathModel, it -> ContainerUtil.map( | ||
buildScriptClasspathModel.getClasspath(), | ||
(Function<ClasspathEntryModel, BuildScriptClasspathData.ClasspathEntry>)model -> BuildScriptClasspathData.ClasspathEntry | ||
.create(model.getClasses(), model.getSources(), model.getJavadoc())); | ||
.create(model.getClasses(), model.getSources(), model.getJavadoc()))); | ||
} | ||
else { | ||
classpathEntries = ContainerUtil.emptyList(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am confused by the explicit usage of IdentityHashMap here. Are the instances of
GradleBuildScriptClasspathModel
internalized?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, it was my experience that they were always the same, but I don't fully understand why. I can dig deeper to understand.