13 |
13 |
14 import java.io.*; |
14 import java.io.*; |
15 import java.net.URI; |
15 import java.net.URI; |
16 import java.util.*; |
16 import java.util.*; |
17 import org.eclipse.core.filesystem.*; |
17 import org.eclipse.core.filesystem.*; |
|
18 import org.eclipse.core.internal.refresh.RefreshJob; |
18 import org.eclipse.core.internal.resources.*; |
19 import org.eclipse.core.internal.resources.*; |
19 import org.eclipse.core.internal.resources.File; |
20 import org.eclipse.core.internal.resources.File; |
20 import org.eclipse.core.internal.utils.*; |
21 import org.eclipse.core.internal.utils.*; |
21 import org.eclipse.core.resources.*; |
22 import org.eclipse.core.resources.*; |
22 import org.eclipse.core.runtime.*; |
23 import org.eclipse.core.runtime.*; |
729 throw error; |
730 throw error; |
730 return description; |
731 return description; |
731 } |
732 } |
732 |
733 |
733 public boolean refresh(IResource target, int depth, boolean updateAliases, IProgressMonitor monitor) throws CoreException { |
734 public boolean refresh(IResource target, int depth, boolean updateAliases, IProgressMonitor monitor) throws CoreException { |
|
735 long startTimeMs = System.currentTimeMillis(); |
|
736 boolean result = refreshImpl(target, depth, updateAliases, monitor); |
|
737 if (!RefreshJob.isRefreshing()) { |
|
738 long totalMs = System.currentTimeMillis() - startTimeMs; |
|
739 StringBuffer sb = new StringBuffer(); |
|
740 sb.append("Refresh called on "); |
|
741 sb.append(target.getFullPath()); |
|
742 sb.append(" completed in : "); |
|
743 sb.append(totalMs); |
|
744 sb.append("ms"); |
|
745 ResourcesPlugin.writeRefreshLog(sb.toString()); |
|
746 StackTraceElement[] trace = Thread.currentThread().getStackTrace(); |
|
747 for (int i = 2; i < trace.length; i++) { // skip the getStackTrace and dump calls |
|
748 ResourcesPlugin.writeRefreshLog("\tat " + trace[i]); |
|
749 } |
|
750 } |
|
751 return result; |
|
752 } |
|
753 |
|
754 private boolean refreshImpl(IResource target, int depth, boolean updateAliases, IProgressMonitor monitor) throws CoreException { |
734 switch (target.getType()) { |
755 switch (target.getType()) { |
735 case IResource.ROOT : |
756 case IResource.ROOT : |
736 return refreshRoot((IWorkspaceRoot) target, depth, updateAliases, monitor); |
757 return refreshRoot((IWorkspaceRoot) target, depth, updateAliases, monitor); |
737 case IResource.PROJECT : |
758 case IResource.PROJECT : |
738 if (!target.isAccessible()) |
759 if (!target.isAccessible()) |
785 return false; |
806 return false; |
786 boolean changed = false; |
807 boolean changed = false; |
787 // drop the depth by one level since processing the root counts as one level. |
808 // drop the depth by one level since processing the root counts as one level. |
788 depth = depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : depth; |
809 depth = depth == IResource.DEPTH_ONE ? IResource.DEPTH_ZERO : depth; |
789 for (int i = 0; i < projects.length; i++) |
810 for (int i = 0; i < projects.length; i++) |
790 changed |= refresh(projects[i], depth, updateAliases, Policy.subMonitorFor(monitor, 1)); |
811 changed |= refreshImpl(projects[i], depth, updateAliases, Policy.subMonitorFor(monitor, 1)); |
791 return changed; |
812 return changed; |
792 } finally { |
813 } finally { |
793 monitor.done(); |
814 monitor.done(); |
794 } |
815 } |
795 } |
816 } |