lkishalmi commented on a change in pull request #2924:
URL: https://github.com/apache/netbeans/pull/2924#discussion_r623129779
##########
File path:
java/gradle.java/src/org/netbeans/modules/gradle/java/classpath/ClassPathProviderImpl.java
##########
@@ -70,36 +71,58 @@
));
- private final Map<String, SourceSetCP> groups = new HashMap<>();
private final Project project;
private final PropertyChangeListener pcl;
+ private final PropertyChangeListener wPcl;
+
+ // @GuardedBy(this)
+ private volatile Map<String, SourceSetCP> groups = new HashMap<>();
public ClassPathProviderImpl(Project project) {
this.project = project;
this.pcl = (PropertyChangeEvent evt) -> {
if
(NbGradleProject.PROP_PROJECT_INFO.equals(evt.getPropertyName())) {
- GradleJavaProject p =
GradleJavaProject.get(ClassPathProviderImpl.this.project);
- if (p != null) {
- updateGroups(p.getSourceSets().keySet());
- } else {
- //We are no longer a Java Project
- updateGroups(Collections.<String>emptySet());
-
- }
+ updateGroups();
}
if
(NbGradleProject.PROP_RESOURCES.endsWith(evt.getPropertyName())) {
URI uri = (URI) evt.getNewValue();
- if ((uri != null) && (uri.getPath() != null) &&
uri.getPath().endsWith(MODULE_INFO_JAVA)) {
- GradleJavaProject gjp =
GradleJavaProject.get(ClassPathProviderImpl.this.project);
- if (gjp != null) {
- GradleJavaSourceSet ss =
gjp.containingSourceSet(Utilities.toFile(uri));
- if ((ss != null) && (groups.get(ss.getName()) !=
null)) {
- groups.get(ss.getName()).reset();
- }
- }
- }
+ updateResources(uri);
}
};
+ this.wPcl = WeakListeners.propertyChange(pcl, null, project);
+ // by some miracle, the project might have been loaded!
+ NbGradleProject gp = NbGradleProject.get(project);
+ if (gp.isGradleProjectLoaded()) {
+ updateGroups();
+ }
+ NbGradleProject.addPropertyChangeListener(project, wPcl);
+ }
+
+ private void updateResources(URI uri) {
+ if ((uri != null) && (uri.getPath() != null) &&
uri.getPath().endsWith(MODULE_INFO_JAVA)) {
+ GradleJavaProject gjp =
GradleJavaProject.get(ClassPathProviderImpl.this.project);
Review comment:
ClassPathProviderImpl.this.project -> project ?
##########
File path:
extide/gradle/src/org/netbeans/modules/gradle/NbGradleProjectImpl.java
##########
@@ -223,52 +229,179 @@ void detachAllUpdater() {
}
}
- void dumpProject() {
+ synchronized void dumpProject() {
project = null;
+ attemptedQuality = null;
+ loadedProjectSerial = 0;
+ aimedQuality = FALLBACK;
}
- public Quality getAimedQuality() {
+ public final Quality getAimedQuality() {
Review comment:
NbGradleProjectImpl class is already final.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists