Browse files

Code cleanup, remove unused field. Avoid scanning ws projects if affe…

…ct project list is empty.
  • Loading branch information...
1 parent 62a3ddb commit d40665e5722e550130b66e171637b7cfa54a5ca8 @kdvolder kdvolder committed Jan 23, 2013
View
31 ...ore/src/org/springsource/ide/eclipse/gradle/core/autorefresh/GradleWorkspaceListener.java
@@ -40,11 +40,6 @@
*/
public class GradleWorkspaceListener {
- //TODO: it should be user configurable whether this thing is enabled. If it turns out ot be annoying
- // users should be able to either tweak it or disable it completely.
-
- private final IDirtyProjectListener dirtyProjectListener;
-
/**
* Get a set of root GradleProjects that are affected by changes to .gradle files. A root project is considered
* affected if a .gradle file is changed in the project itself or any of its nested projects.
@@ -89,27 +84,27 @@ public boolean visit(IResourceDelta delta) throws CoreException {
}
public GradleWorkspaceListener(final IDirtyProjectListener dirtyProjectListener) {
- this.dirtyProjectListener = dirtyProjectListener;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IResourceChangeListener listener = new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
if (event.getType() != IResourceChangeEvent.POST_CHANGE)
return;
final Set<GradleProject> affectedRootProjects = getAffectedRootProjects(event);
-
- for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
- if (GradleNature.hasNature(p)) {
- GradleProject gp = GradleCore.create(p);
- if (GradleClassPathContainer.isOnClassPath(gp.getJavaProject())) {
- //Auto refresh is limited to projects that have dependency management
- //enabled. It may be possible to broaden this.
- try {
- if (affectedRootProjects.contains(gp.getRootProject())) {
- dirtyProjectListener.addDirty(gp);
+ if (!affectedRootProjects.isEmpty()) {
+ for (IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ if (GradleNature.hasNature(p)) {
+ GradleProject gp = GradleCore.create(p);
+ if (GradleClassPathContainer.isOnClassPath(gp.getJavaProject())) {
+ //Auto refresh is limited to projects that have dependency management
+ //enabled. It may be possible to broaden this.
+ try {
+ if (affectedRootProjects.contains(gp.getRootProject())) {
+ dirtyProjectListener.addDirty(gp);
+ }
+ } catch (FastOperationFailedException e) {
+ //ignore
}
- } catch (FastOperationFailedException e) {
- //ignore
}
}
}

0 comments on commit d40665e

Please sign in to comment.