Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Ptaszkiewicz2014-07-18 15:57:59 +0000
committerSzymon Ptaszkiewicz2014-07-18 15:57:59 +0000
commit7b0b1f52da9530eb69f7ffe75715d86ef5d7452c (patch)
tree23b451c8ad36d037ee8254d32a575a80d5eeac42
parente332a711becfbd40358308857dd4b69defbd1299 (diff)
downloadeclipse.platform.resources-7b0b1f52da9530eb69f7ffe75715d86ef5d7452c.tar.gz
eclipse.platform.resources-7b0b1f52da9530eb69f7ffe75715d86ef5d7452c.tar.xz
eclipse.platform.resources-7b0b1f52da9530eb69f7ffe75715d86ef5d7452c.zip
Bug 431876 - Add all Resources plugins to General > Tracing preference page
-rw-r--r--bundles/org.eclipse.core.resources/plugin.properties6
-rw-r--r--bundles/org.eclipse.core.resources/plugin.xml11
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java14
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java15
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java8
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/MonitorManager.java34
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/PollingMonitor.java23
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshJob.java18
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java5
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java6
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java68
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java2
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java24
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java112
-rw-r--r--bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java18
15 files changed, 197 insertions, 167 deletions
diff --git a/bundles/org.eclipse.core.resources/plugin.properties b/bundles/org.eclipse.core.resources/plugin.properties
index c36106248..1c45ea381 100644
--- a/bundles/org.eclipse.core.resources/plugin.properties
+++ b/bundles/org.eclipse.core.resources/plugin.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2010 IBM Corporation and others.
+# Copyright (c) 2000, 2014 IBM Corporation and others.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
@@ -35,4 +35,6 @@ compatibilityFragmentName = Core Resource Management Compatibility Fragment
win32MonitorFactoryName = Windows Auto-refresh monitor
regexFilterProvider.description = Matches file and folder names with a regular expression
-regexFilterProvider.name = Regular Expression \ No newline at end of file
+regexFilterProvider.name = Regular Expression
+
+trace.component.label = Platform Core Resources
diff --git a/bundles/org.eclipse.core.resources/plugin.xml b/bundles/org.eclipse.core.resources/plugin.xml
index a7c993213..94961ecd6 100644
--- a/bundles/org.eclipse.core.resources/plugin.xml
+++ b/bundles/org.eclipse.core.resources/plugin.xml
@@ -235,4 +235,15 @@
</run>
</filesystem>
</extension>
+ <extension
+ point="org.eclipse.ui.trace.traceComponents">
+ <component
+ id="org.eclipse.core.resources.trace"
+ label="%trace.component.label">
+ <bundle
+ consumed="false"
+ name="org.eclipse.core.resources">
+ </bundle>
+ </component>
+ </extension>
</plugin>
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
index 022046703..a230028ff 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/AutoBuildJob.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2003, 2010 IBM Corporation and others.
+ * Copyright (c) 2003, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -76,7 +76,7 @@ class AutoBuildJob extends Job implements Preferences.IPropertyChangeListener {
if (Policy.DEBUG_BUILD_NEEDED)
Policy.debug("Auto-Build requested, needsBuild: " + needsBuild + " state: " + state + " delay: " + delay); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (needsBuild && Policy.DEBUG_BUILD_NEEDED_STACK && state != Job.RUNNING)
- new RuntimeException("Build Needed").printStackTrace(); //$NON-NLS-1$
+ Policy.debug(new RuntimeException("Build needed")); //$NON-NLS-1$
//don't mess with the interrupt flag if the job is still running
if (state != Job.RUNNING)
setInterrupted(false);
@@ -120,7 +120,7 @@ class AutoBuildJob extends Job implements Preferences.IPropertyChangeListener {
//schedule a rebuild immediately if build was implicitly canceled
if (interrupted) {
if (Policy.DEBUG_BUILD_INTERRUPT)
- System.out.println("Scheduling rebuild due to interruption"); //$NON-NLS-1$
+ Policy.debug("Scheduling rebuild due to interruption"); //$NON-NLS-1$
setInterrupted(false);
schedule(computeScheduleDelay());
}
@@ -159,7 +159,7 @@ class AutoBuildJob extends Job implements Preferences.IPropertyChangeListener {
monitor.done();
}
}
-
+
/**
* Forces an autobuild to occur, even if nothing has changed since the last
* build. This is used to force a build after a clean.
@@ -188,10 +188,8 @@ class AutoBuildJob extends Job implements Preferences.IPropertyChangeListener {
if (Job.getJobManager().currentJob() == this)
return;
setInterrupted(true);
- if (interrupted && Policy.DEBUG_BUILD_INTERRUPT) {
- System.out.println("Autobuild was interrupted:"); //$NON-NLS-1$
- new Exception().fillInStackTrace().printStackTrace();
- }
+ if (interrupted && Policy.DEBUG_BUILD_INTERRUPT)
+ Policy.debug(new RuntimeException("Autobuild was interrupted")); //$NON-NLS-1$
break;
}
//clear the autobuild avoidance flag if we were interrupted
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java
index 4c320a442..7baf2f6a2 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/BuildManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,8 +14,6 @@
*******************************************************************************/
package org.eclipse.core.internal.events;
-import java.io.PrintWriter;
-import java.io.StringWriter;
import java.util.*;
import org.eclipse.core.internal.dtree.DeltaDataTree;
import org.eclipse.core.internal.resources.*;
@@ -827,15 +825,8 @@ public class BuildManager implements ICoreConstants, IManager, ILifecycleListene
*/
private void hookStartBuild(IBuildConfiguration[] configs, int trigger) {
building = true;
- if (Policy.DEBUG_BUILD_STACK) {
- StringWriter writer = new StringWriter();
- writer.write("Starting build: " + debugTrigger(trigger) + " from:\n"); //$NON-NLS-1$ //$NON-NLS-2$
- new RuntimeException().fillInStackTrace().printStackTrace(new PrintWriter(writer));
- String str = writer.toString();
- if (str.endsWith("\n")) //$NON-NLS-1$
- str = str.substring(0, str.length() - 2);
- Policy.debug(str);
- }
+ if (Policy.DEBUG_BUILD_STACK)
+ Policy.debug(new RuntimeException("Starting build: " + debugTrigger(trigger))); //$NON-NLS-1$
if (Policy.DEBUG_BUILD_INVOKING) {
overallTimeStamp = System.currentTimeMillis();
StringBuffer sb = new StringBuffer("Top-level build-start of: "); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java
index c36e286ce..15f1dbac9 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/localstore/HistoryStore2.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -84,7 +84,7 @@ public class HistoryStore2 implements IHistoryStore {
public synchronized IFileState addState(IPath key, IFileStore localFile, IFileInfo info, boolean moveContents) {
long lastModified = info.getLastModified();
if (Policy.DEBUG_HISTORY)
- System.out.println("History: Adding state for key: " + key + ", file: " + localFile + ", timestamp: " + lastModified + ", size: " + localFile.fetchInfo().getLength()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Policy.debug("History: Adding state for key: " + key + ", file: " + localFile + ", timestamp: " + lastModified + ", size: " + localFile.fetchInfo().getLength()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
if (!isValid(localFile, info))
return null;
UniversalUniqueIdentifier uuid = null;
@@ -180,7 +180,7 @@ public class HistoryStore2 implements IHistoryStore {
monitor.done();
}
}
-
+
/*
* Remove blobs from the blobStore. When the size of blobsToRemove exceeds the limit,
* remove the given blobs from blobStore. If the limit is zero or negative, remove blobs
@@ -303,7 +303,7 @@ public class HistoryStore2 implements IHistoryStore {
long length = info.getLength();
boolean result = length <= description.getMaxFileStateSize();
if (Policy.DEBUG_HISTORY && !result)
- System.out.println("History: Ignoring file (too large). File: " + localFile.toString() + //$NON-NLS-1$
+ Policy.debug("History: Ignoring file (too large). File: " + localFile.toString() + //$NON-NLS-1$
", size: " + length + //$NON-NLS-1$
", max: " + description.getMaxFileStateSize()); //$NON-NLS-1$
return result;
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/MonitorManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/MonitorManager.java
index 2740490dd..dd13cef75 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/MonitorManager.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/MonitorManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -112,9 +112,9 @@ class MonitorManager implements ILifecycleListener, IPathVariableChangeListener,
public void handleEvent(LifecycleEvent event) {
switch (event.kind) {
- case LifecycleEvent.PRE_LINK_DELETE:
- case LifecycleEvent.PRE_PROJECT_CLOSE:
- case LifecycleEvent.PRE_PROJECT_DELETE:
+ case LifecycleEvent.PRE_LINK_DELETE :
+ case LifecycleEvent.PRE_PROJECT_CLOSE :
+ case LifecycleEvent.PRE_PROJECT_DELETE :
unmonitor(event.resource);
break;
}
@@ -158,8 +158,8 @@ class MonitorManager implements ILifecycleListener, IPathVariableChangeListener,
* @see IRefreshResult#monitorFailed
*/
public void monitorFailed(IRefreshMonitor monitor, IResource resource) {
- if (RefreshManager.DEBUG)
- System.err.println(RefreshManager.DEBUG_PREFIX + " monitor (" + monitor + ") failed to monitor resource: " + resource); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + " monitor (" + monitor + ") failed to monitor resource: " + resource); //$NON-NLS-1$ //$NON-NLS-2$
if (registeredMonitors == null || monitor == null)
return;
if (resource == null) {
@@ -223,8 +223,8 @@ class MonitorManager implements ILifecycleListener, IPathVariableChangeListener,
if (!resources.contains(resource))
resources.add(resource);
}
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + " added monitor (" + monitor + ") on resource: " + resource); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + " added monitor (" + monitor + ") on resource: " + resource); //$NON-NLS-1$ //$NON-NLS-2$
}
private void removeMonitor(IRefreshMonitor monitor, IResource resource) {
@@ -236,8 +236,8 @@ class MonitorManager implements ILifecycleListener, IPathVariableChangeListener,
else
registeredMonitors.remove(monitor);
}
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + " removing monitor (" + monitor + ") on resource: " + resource); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + " removing monitor (" + monitor + ") on resource: " + resource); //$NON-NLS-1$ //$NON-NLS-2$
}
private IRefreshMonitor safeInstallMonitor(RefreshProvider provider, IResource resource) {
@@ -264,9 +264,9 @@ class MonitorManager implements ILifecycleListener, IPathVariableChangeListener,
workspace.getPathVariableManager().addChangeListener(this);
workspace.addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
//adding the lifecycle listener twice does no harm
- ((Workspace)workspace).addLifecycleListener(this);
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + " starting monitor manager."); //$NON-NLS-1$
+ ((Workspace) workspace).addLifecycleListener(this);
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + " starting monitor manager."); //$NON-NLS-1$
//If not exclusively using polling, create a polling monitor and run it once, to catch
//changes that occurred while the native monitor was turned off.
if (refreshNeeded)
@@ -287,8 +287,8 @@ class MonitorManager implements ILifecycleListener, IPathVariableChangeListener,
}
}
registeredMonitors.clear();
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + " stopping monitor manager."); //$NON-NLS-1$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + " stopping monitor manager."); //$NON-NLS-1$
pollMonitor.cancel();
}
@@ -306,7 +306,7 @@ class MonitorManager implements ILifecycleListener, IPathVariableChangeListener,
}
}
if (resource.getType() == IResource.PROJECT)
- unmonitorLinkedContents((IProject)resource);
+ unmonitorLinkedContents((IProject) resource);
}
private void unmonitorLinkedContents(IProject project) {
@@ -336,7 +336,7 @@ class MonitorManager implements ILifecycleListener, IPathVariableChangeListener,
}
public boolean visit(IResourceDelta delta) {
- if (delta.getKind () == IResourceDelta.ADDED) {
+ if (delta.getKind() == IResourceDelta.ADDED) {
IResource resource = delta.getResource();
if (resource.isLinked())
monitor(resource);
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/PollingMonitor.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/PollingMonitor.java
index ff412090f..2c8c64549 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/PollingMonitor.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/PollingMonitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@ package org.eclipse.core.internal.refresh;
import java.util.ArrayList;
import org.eclipse.core.internal.resources.Resource;
import org.eclipse.core.internal.utils.Messages;
+import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.resources.*;
import org.eclipse.core.resources.refresh.IRefreshMonitor;
import org.eclipse.core.runtime.*;
@@ -113,12 +114,12 @@ public class PollingMonitor extends Job implements IRefreshMonitor {
//check to see if we need to start an iteration
if (toRefresh.isEmpty()) {
beginIteration();
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + "New polling iteration on " + toRefresh.size() + " roots"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + "New polling iteration on " + toRefresh.size() + " roots"); //$NON-NLS-1$ //$NON-NLS-2$
}
final int oldSize = toRefresh.size();
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + "started polling"); //$NON-NLS-1$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + "started polling"); //$NON-NLS-1$
//refresh the hot root if applicable
if (time - hotRootTime > HOT_ROOT_DECAY)
hotRoot = null;
@@ -135,16 +136,16 @@ public class PollingMonitor extends Job implements IRefreshMonitor {
break;
}
time = System.currentTimeMillis() - time;
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + "polled " + (oldSize - toRefresh.size()) + " roots in " + time + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + "polled " + (oldSize - toRefresh.size()) + " roots in " + time + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
//reschedule automatically - shouldRun will cancel if not needed
//make sure it doesn't run more than 5% of the time
long delay = Math.max(MIN_FREQUENCY, time * 20);
//back off even more if there are other jobs running
if (!getJobManager().isIdle())
delay *= 2;
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + "rescheduling polling job in: " + delay / 1000 + " seconds"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + "rescheduling polling job in: " + delay / 1000 + " seconds"); //$NON-NLS-1$ //$NON-NLS-2$
//don't reschedule the job if the resources plugin has been shut down
if (Platform.getBundle(ResourcesPlugin.PI_RESOURCES).getState() == Bundle.ACTIVE)
schedule(delay);
@@ -179,8 +180,8 @@ public class PollingMonitor extends Job implements IRefreshMonitor {
refreshManager.refresh(resource);
hotRoot = resource;
hotRootTime = System.currentTimeMillis();
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + "new hot root: " + resource); //$NON-NLS-1$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + "new hot root: " + resource); //$NON-NLS-1$
}
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshJob.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshJob.java
index c4a8d3b02..cbb513b4d 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshJob.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshJob.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -103,7 +103,7 @@ public class RefreshJob extends WorkspaceJob {
}
return children;
}
-
+
/**
* Returns the path prefixes visited by this job so far.
*/
@@ -152,7 +152,7 @@ public class RefreshJob extends WorkspaceJob {
MultiStatus errors = new MultiStatus(ResourcesPlugin.PI_RESOURCES, 1, msg, null);
long longestRefresh = 0;
try {
- if (RefreshManager.DEBUG)
+ if (Policy.DEBUG_AUTO_REFRESH)
Policy.debug(RefreshManager.DEBUG_PREFIX + " starting refresh job"); //$NON-NLS-1$
int refreshCount = 0;
int depth = 2;
@@ -192,8 +192,8 @@ public class RefreshJob extends WorkspaceJob {
pathPrefixHistory = null;
rootPathHistory = null;
monitor.done();
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + " finished refresh job in: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + " finished refresh job in: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
if (!errors.isOK())
return errors;
@@ -211,16 +211,16 @@ public class RefreshJob extends WorkspaceJob {
* Starts the refresh job
*/
public void start() {
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + " enabling auto-refresh"); //$NON-NLS-1$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + " enabling auto-refresh"); //$NON-NLS-1$
}
/**
* Stops the refresh job
*/
public void stop() {
- if (RefreshManager.DEBUG)
- System.out.println(RefreshManager.DEBUG_PREFIX + " disabling auto-refresh"); //$NON-NLS-1$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(RefreshManager.DEBUG_PREFIX + " disabling auto-refresh"); //$NON-NLS-1$
cancel();
}
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java
index ec0ebb58a..30c573a36 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/refresh/RefreshManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
+ * Copyright (c) 2004, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,7 +11,6 @@
package org.eclipse.core.internal.refresh;
import org.eclipse.core.internal.resources.IManager;
-import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.resources.*;
import org.eclipse.core.resources.refresh.IRefreshMonitor;
import org.eclipse.core.resources.refresh.IRefreshResult;
@@ -26,8 +25,6 @@ import org.eclipse.core.runtime.Preferences.PropertyChangeEvent;
* @since 3.0
*/
public class RefreshManager implements IRefreshResult, IManager, Preferences.IPropertyChangeListener {
-
- public static boolean DEBUG = Policy.DEBUG_AUTO_REFRESH;
public static final String DEBUG_PREFIX = "Auto-refresh: "; //$NON-NLS-1$
MonitorManager monitors;
private RefreshJob refreshJob;
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java
index 85f469da4..8e42bf8c9 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/NatureManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2012 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -154,7 +154,7 @@ public class NatureManager implements ILifecycleListener, IManager {
}
};
if (Policy.DEBUG_NATURES) {
- System.out.println("Configuring nature: " + natureID + " on project: " + project.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Configuring nature: " + natureID + " on project: " + project.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
SafeRunner.run(code);
}
@@ -269,7 +269,7 @@ public class NatureManager implements ILifecycleListener, IManager {
}
};
if (Policy.DEBUG_NATURES) {
- System.out.println("Deconfiguring nature: " + natureID + " on project: " + project.getName()); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Deconfiguring nature: " + natureID + " on project: " + project.getName()); //$NON-NLS-1$ //$NON-NLS-2$
}
SafeRunner.run(code);
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java
index 8ab488cc1..bf5dd468a 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/SaveManager.java
@@ -457,7 +457,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
break;
}
if (endMessage != null)
- System.out.println(endMessage + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$
+ Policy.debug(endMessage + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$
}
}
@@ -471,13 +471,13 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
if (Policy.DEBUG_SAVE) {
switch (kind) {
case ISaveContext.FULL_SAVE :
- System.out.println(DEBUG_FULL_SAVE + DEBUG_START);
+ Policy.debug(DEBUG_FULL_SAVE + DEBUG_START);
break;
case ISaveContext.SNAPSHOT :
- System.out.println(DEBUG_SNAPSHOT + DEBUG_START);
+ Policy.debug(DEBUG_SNAPSHOT + DEBUG_START);
break;
case ISaveContext.PROJECT_SAVE :
- System.out.println(DEBUG_PROJECT_SAVE + project.getFullPath() + DEBUG_START);
+ Policy.debug(DEBUG_PROJECT_SAVE + project.getFullPath() + DEBUG_START);
break;
}
}
@@ -682,7 +682,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
*/
protected void restore(IProgressMonitor monitor) throws CoreException {
if (Policy.DEBUG_RESTORE)
- System.out.println("Restore workspace: starting..."); //$NON-NLS-1$
+ Policy.debug("Restore workspace: starting..."); //$NON-NLS-1$
long start = System.currentTimeMillis();
monitor = Policy.monitorFor(monitor);
try {
@@ -725,7 +725,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
monitor.done();
}
if (Policy.DEBUG_RESTORE)
- System.out.println("Restore workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Restore workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -738,7 +738,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
protected boolean restore(Project project, IProgressMonitor monitor) throws CoreException {
boolean status = true;
if (Policy.DEBUG_RESTORE)
- System.out.println("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$
long start = System.currentTimeMillis();
monitor = Policy.monitorFor(monitor);
try {
@@ -756,7 +756,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
monitor.done();
}
if (Policy.DEBUG_RESTORE)
- System.out.println("Restore project " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Restore project " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return status;
}
@@ -775,7 +775,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
if (!snapshotFile.exists())
return false;
if (Policy.DEBUG_RESTORE)
- System.out.println("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Restore project " + project.getFullPath() + ": starting..."); //$NON-NLS-1$ //$NON-NLS-2$
long start = System.currentTimeMillis();
monitor = Policy.monitorFor(monitor);
try {
@@ -791,7 +791,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
monitor.done();
}
if (Policy.DEBUG_RESTORE)
- System.out.println("Restore project " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Restore project " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return status;
}
@@ -810,7 +810,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
// if we have the workspace root then restore markers for its projects
if (resource.getType() == IResource.PROJECT) {
if (Policy.DEBUG_RESTORE_MARKERS) {
- System.out.println("Restore Markers for " + resource.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Restore Markers for " + resource.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
return;
}
@@ -819,7 +819,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
if (projects[i].isAccessible())
markerManager.restore(projects[i], generateDeltas, monitor);
if (Policy.DEBUG_RESTORE_MARKERS) {
- System.out.println("Restore Markers for workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Restore Markers for workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -846,7 +846,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
throw new ResourceException(IResourceStatus.INTERNAL_ERROR, null, message, e);
}
if (Policy.DEBUG_RESTORE_MASTERTABLE)
- System.out.println("Restore master table for " + location + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Restore master table for " + location + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/**
@@ -855,7 +855,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
*/
protected void restoreMetaInfo(MultiStatus problems, IProgressMonitor monitor) {
if (Policy.DEBUG_RESTORE_METAINFO)
- System.out.println("Restore workspace metainfo: starting..."); //$NON-NLS-1$
+ Policy.debug("Restore workspace metainfo: starting..."); //$NON-NLS-1$
long start = System.currentTimeMillis();
IProject[] roots = workspace.getRoot().getProjects(IContainer.INCLUDE_HIDDEN);
for (int i = 0; i < roots.length; i++) {
@@ -868,7 +868,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
}
}
if (Policy.DEBUG_RESTORE_METAINFO)
- System.out.println("Restore workspace metainfo: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Restore workspace metainfo: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -907,7 +907,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
throw failure;
}
if (Policy.DEBUG_RESTORE_METAINFO)
- System.out.println("Restore metainfo for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Restore metainfo for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/**
@@ -966,7 +966,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
monitor.done();
}
if (Policy.DEBUG_RESTORE_SNAPSHOTS)
- System.out.println("Restore snapshots for workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Restore snapshots for workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -1003,7 +1003,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
// restore sync info for all projects if we were given the workspace root.
if (resource.getType() == IResource.PROJECT) {
if (Policy.DEBUG_RESTORE_SYNCINFO) {
- System.out.println("Restore SyncInfo for " + resource.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Restore SyncInfo for " + resource.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
return;
}
@@ -1012,7 +1012,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
if (projects[i].isAccessible())
synchronizer.restore(projects[i], monitor);
if (Policy.DEBUG_RESTORE_SYNCINFO) {
- System.out.println("Restore SyncInfo for workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Restore SyncInfo for workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -1042,7 +1042,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
throw new ResourceException(IResourceStatus.FAILED_READ_METADATA, treeLocation, msg, e);
}
if (Policy.DEBUG_RESTORE_TREE) {
- System.out.println("Restore Tree for workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Restore Tree for workspace: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -1079,7 +1079,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
monitor.done();
}
if (Policy.DEBUG_RESTORE_TREE) {
- System.out.println("Restore Tree for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Restore Tree for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
return true;
}
@@ -1119,7 +1119,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
monitor.done();
}
if (Policy.DEBUG_RESTORE_TREE) {
- System.out.println("Restore Tree for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Restore Tree for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
return true;
}
@@ -1273,7 +1273,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
throw new ResourceException(IResourceStatus.INTERNAL_ERROR, null, NLS.bind(Messages.resources_exSaveMaster, location.toOSString()), e);
}
if (Policy.DEBUG_SAVE_MASTERTABLE)
- System.out.println("Save master table for " + location + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Save master table for " + location + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/**
@@ -1282,7 +1282,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
*/
protected void saveMetaInfo(MultiStatus problems, IProgressMonitor monitor) throws CoreException {
if (Policy.DEBUG_SAVE_METAINFO)
- System.out.println("Save workspace metainfo: starting..."); //$NON-NLS-1$
+ Policy.debug("Save workspace metainfo: starting..."); //$NON-NLS-1$
long start = System.currentTimeMillis();
// save preferences (workspace description, path variables, etc)
ResourcesPlugin.getPlugin().savePluginPreferences();
@@ -1295,7 +1295,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
problems.merge(result);
}
if (Policy.DEBUG_SAVE_METAINFO)
- System.out.println("Save workspace metainfo: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Save workspace metainfo: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -1314,7 +1314,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
return new ResourceStatus(IResourceStatus.MISSING_DESCRIPTION_REPAIRED, project.getFullPath(), msg);
}
if (Policy.DEBUG_SAVE_METAINFO)
- System.out.println("Save metainfo for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Save metainfo for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
return Status.OK_STATUS;
}
@@ -1396,7 +1396,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, Path.ROOT, msg, e);
}
if (Policy.DEBUG_SAVE_TREE)
- System.out.println("Save Workspace Tree: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Save Workspace Tree: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -1448,7 +1448,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
operationCount++;
if (snapshotJob.getState() == Job.NONE) {
if (Policy.DEBUG_SAVE)
- System.out.println("Scheduling workspace snapshot"); //$NON-NLS-1$
+ Policy.debug("Scheduling workspace snapshot"); //$NON-NLS-1$
long interval = workspace.internalGetDescription().getSnapshotInterval();
snapshotJob.schedule(Math.max(interval, MIN_SNAPSHOT_DELAY));
}
@@ -1501,7 +1501,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
monitor.done();
}
if (Policy.DEBUG_SAVE_TREE)
- System.out.println("Snapshot Workspace Tree: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ Policy.debug("Snapshot Workspace Tree: " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -1689,9 +1689,9 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
throw (IOException) e.getTargetException();
}
if (Policy.DEBUG_SAVE_MARKERS)
- System.out.println("Save Markers for " + root.getFullPath() + ": " + saveTimes[0] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Save Markers for " + root.getFullPath() + ": " + saveTimes[0] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (Policy.DEBUG_SAVE_SYNCINFO)
- System.out.println("Save SyncInfo for " + root.getFullPath() + ": " + saveTimes[1] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Save SyncInfo for " + root.getFullPath() + ": " + saveTimes[1] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
removeGarbage(markersOutput, markersLocation, markersTempLocation);
// if we have the workspace root the output stream will be null and we
// don't have to perform cleanup code
@@ -1802,9 +1802,9 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
throw (IOException) e.getTargetException();
}
if (Policy.DEBUG_SAVE_MARKERS)
- System.out.println("Snap Markers for " + root.getFullPath() + ": " + snapTimes[0] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Snap Markers for " + root.getFullPath() + ": " + snapTimes[0] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (Policy.DEBUG_SAVE_SYNCINFO)
- System.out.println("Snap SyncInfo for " + root.getFullPath() + ": " + snapTimes[1] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Snap SyncInfo for " + root.getFullPath() + ": " + snapTimes[1] + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
if (markerFileSize != markersOutput.size())
safeMarkerStream.succeed();
if (safeSyncInfoStream != null && syncInfoFileSize != syncInfoOutput.size()) {
@@ -2096,7 +2096,7 @@ public class SaveManager implements IElementInfoFlattener, IManager, IStringPool
throw new ResourceException(IResourceStatus.FAILED_WRITE_METADATA, treeLocation, msg, e);
}
if (Policy.DEBUG_SAVE_TREE)
- System.out.println("Save tree for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Policy.debug("Save tree for " + project.getFullPath() + ": " + (System.currentTimeMillis() - start) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
protected void writeWorkspaceFields(DataOutputStream output, IProgressMonitor monitor) throws IOException {
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java
index 0f94c390a..1c0ca5706 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/Workspace.java
@@ -2360,7 +2360,7 @@ public class Workspace extends PlatformObject implements IWorkspace, ICoreConsta
String msg = "The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes."; //$NON-NLS-1$
Policy.log(new ResourceStatus(ICoreConstants.CRASH_DETECTED, msg));
if (Policy.DEBUG)
- System.out.println(msg);
+ Policy.debug(msg);
}
}
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java
index fb34b0b1f..8735880fc 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/resources/refresh/win32/Win32Monitor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2012 IBM Corporation and others.
+ * Copyright (c) 2002, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,8 +13,8 @@ package org.eclipse.core.internal.resources.refresh.win32;
import java.io.File;
import java.util.*;
-import org.eclipse.core.internal.refresh.RefreshManager;
import org.eclipse.core.internal.utils.Messages;
+import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.refresh.IRefreshMonitor;
@@ -140,8 +140,8 @@ class Win32Monitor extends Job implements IRefreshMonitor {
if (error != Win32Natives.ERROR_INVALID_HANDLE)
addException(NLS.bind(Messages.WM_errCloseHandle, Integer.toString(error)));
}
- if (RefreshManager.DEBUG)
- System.out.println(DEBUG_PREFIX + "removed handle: " + handleValue); //$NON-NLS-1$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(DEBUG_PREFIX + "removed handle: " + handleValue); //$NON-NLS-1$
handleValue = Win32Natives.INVALID_HANDLE_VALUE;
}
}
@@ -451,8 +451,8 @@ class Win32Monitor extends Job implements IRefreshMonitor {
}
//make sure the job is running
schedule(RESCHEDULE_DELAY);
- if (RefreshManager.DEBUG)
- System.out.println(DEBUG_PREFIX + " added monitor for: " + resource); //$NON-NLS-1$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(DEBUG_PREFIX + " added monitor for: " + resource); //$NON-NLS-1$
return true;
}
@@ -494,8 +494,8 @@ class Win32Monitor extends Job implements IRefreshMonitor {
*/
protected IStatus run(IProgressMonitor monitor) {
long start = -System.currentTimeMillis();
- if (RefreshManager.DEBUG)
- System.out.println(DEBUG_PREFIX + "job started."); //$NON-NLS-1$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(DEBUG_PREFIX + "job started."); //$NON-NLS-1$
try {
long[][] handleArrays = getHandleValueArrays();
monitor.beginTask(Messages.WM_beginTask, handleArrays.length);
@@ -510,13 +510,13 @@ class Win32Monitor extends Job implements IRefreshMonitor {
} finally {
monitor.done();
start += System.currentTimeMillis();
- if (RefreshManager.DEBUG)
- System.out.println(DEBUG_PREFIX + "job finished in: " + start + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(DEBUG_PREFIX + "job finished in: " + start + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
}
//always reschedule the job - so it will come back after errors or cancelation
long delay = Math.max(RESCHEDULE_DELAY, start);
- if (RefreshManager.DEBUG)
- System.out.println(DEBUG_PREFIX + "rescheduling in: " + delay / 1000 + " seconds"); //$NON-NLS-1$ //$NON-NLS-2$
+ if (Policy.DEBUG_AUTO_REFRESH)
+ Policy.debug(DEBUG_PREFIX + "rescheduling in: " + delay / 1000 + " seconds"); //$NON-NLS-1$ //$NON-NLS-2$
final Bundle bundle = Platform.getBundle(ResourcesPlugin.PI_RESOURCES);
//if the bundle is null then the framework has shutdown - just bail out completely (bug 98219)
if (bundle == null)
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java
index f2ad5c1b9..547775885 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/utils/Policy.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,12 +10,55 @@
*******************************************************************************/
package org.eclipse.core.internal.utils;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.Date;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.*;
+import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.osgi.framework.Bundle;
public class Policy {
+ public static final DebugOptionsListener RESOURCES_DEBUG_OPTIONS_LISTENER = new DebugOptionsListener() {
+ public void optionsChanged(DebugOptions options) {
+ DEBUG = options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/debug", false); //$NON-NLS-1$
+
+ DEBUG_AUTO_REFRESH = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/refresh", false); //$NON-NLS-1$
+
+ DEBUG_BUILD_DELTA = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/build/delta", false); //$NON-NLS-1$
+ DEBUG_BUILD_FAILURE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/build/failure", false); //$NON-NLS-1$
+ DEBUG_BUILD_INTERRUPT = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/build/interrupt", false); //$NON-NLS-1$
+ DEBUG_BUILD_INVOKING = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/build/invoking", false); //$NON-NLS-1$
+ DEBUG_BUILD_NEEDED = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/build/needbuild", false); //$NON-NLS-1$
+ DEBUG_BUILD_NEEDED_STACK = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/build/needbuildstack", false); //$NON-NLS-1$
+ DEBUG_BUILD_STACK = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/build/stacktrace", false); //$NON-NLS-1$
+
+ DEBUG_CONTENT_TYPE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/contenttype", false); //$NON-NLS-1$
+ DEBUG_CONTENT_TYPE_CACHE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/contenttype/cache", false); //$NON-NLS-1$
+ DEBUG_HISTORY = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/history", false); //$NON-NLS-1$
+ DEBUG_NATURES = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/natures", false); //$NON-NLS-1$
+ DEBUG_PREFERENCES = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/preferences", false); //$NON-NLS-1$
+
+ DEBUG_RESTORE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/restore", false); //$NON-NLS-1$
+ DEBUG_RESTORE_MARKERS = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/restore/markers", false); //$NON-NLS-1$
+ DEBUG_RESTORE_MASTERTABLE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/restore/mastertable", false); //$NON-NLS-1$
+ DEBUG_RESTORE_METAINFO = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/restore/metainfo", false); //$NON-NLS-1$
+ DEBUG_RESTORE_SNAPSHOTS = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/restore/snapshots", false); //$NON-NLS-1$
+ DEBUG_RESTORE_SYNCINFO = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/restore/syncinfo", false); //$NON-NLS-1$
+ DEBUG_RESTORE_TREE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/restore/tree", false); //$NON-NLS-1$
+
+ DEBUG_SAVE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/save", false); //$NON-NLS-1$
+ DEBUG_SAVE_MARKERS = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/save/markers", false); //$NON-NLS-1$
+ DEBUG_SAVE_MASTERTABLE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/save/mastertable", false); //$NON-NLS-1$
+ DEBUG_SAVE_METAINFO = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/save/metainfo", false); //$NON-NLS-1$
+ DEBUG_SAVE_SYNCINFO = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/save/syncinfo", false); //$NON-NLS-1$
+ DEBUG_SAVE_TREE = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/save/tree", false); //$NON-NLS-1$
+
+ DEBUG_STRINGS = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/strings", false); //$NON-NLS-1$
+ }
+ };
+
public static final boolean buildOnCancel = false;
//general debug flag for the plugin
public static boolean DEBUG = false;
@@ -61,46 +104,6 @@ public class Policy {
public static int opWork = 99;
public static final int totalWork = 100;
- static {
- //init debug options
- if (ResourcesPlugin.getPlugin().isDebugging()) {
- DEBUG = true;
- String sTrue = Boolean.TRUE.toString();
- DEBUG_AUTO_REFRESH = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/refresh")); //$NON-NLS-1$
-
- DEBUG_BUILD_DELTA = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/build/delta")); //$NON-NLS-1$
- DEBUG_BUILD_FAILURE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/build/failure")); //$NON-NLS-1$
- DEBUG_BUILD_INVOKING = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/build/invoking")); //$NON-NLS-1$
- DEBUG_BUILD_INTERRUPT = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/build/interrupt")); //$NON-NLS-1$
- DEBUG_BUILD_NEEDED = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/build/needbuild")); //$NON-NLS-1$
- DEBUG_BUILD_NEEDED_STACK = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/build/needbuildstack")); //$NON-NLS-1$
- DEBUG_BUILD_STACK = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/build/stacktrace")); //$NON-NLS-1$
-
- DEBUG_CONTENT_TYPE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/contenttype")); //$NON-NLS-1$
- DEBUG_CONTENT_TYPE_CACHE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/contenttype/cache")); //$NON-NLS-1$
- DEBUG_HISTORY = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/history")); //$NON-NLS-1$
- DEBUG_NATURES = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/natures")); //$NON-NLS-1$
- DEBUG_PREFERENCES = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/preferences")); //$NON-NLS-1$
-
- DEBUG_RESTORE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/restore")); //$NON-NLS-1$
- DEBUG_RESTORE_MARKERS = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/restore/markers")); //$NON-NLS-1$
- DEBUG_RESTORE_MASTERTABLE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/restore/mastertable")); //$NON-NLS-1$
- DEBUG_RESTORE_METAINFO = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/restore/metainfo")); //$NON-NLS-1$
- DEBUG_RESTORE_SNAPSHOTS = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/restore/snapshots")); //$NON-NLS-1$
- DEBUG_RESTORE_SYNCINFO = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/restore/syncinfo")); //$NON-NLS-1$
- DEBUG_RESTORE_TREE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/restore/tree")); //$NON-NLS-1$
-
- DEBUG_SAVE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/save")); //$NON-NLS-1$
- DEBUG_SAVE_MARKERS = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/save/markers")); //$NON-NLS-1$
- DEBUG_SAVE_MASTERTABLE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/save/mastertable")); //$NON-NLS-1$
- DEBUG_SAVE_METAINFO = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/save/metainfo")); //$NON-NLS-1$
- DEBUG_SAVE_SYNCINFO = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/save/syncinfo")); //$NON-NLS-1$
- DEBUG_SAVE_TREE = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/save/tree")); //$NON-NLS-1$
-
- DEBUG_STRINGS = sTrue.equalsIgnoreCase(Platform.getDebugOption(ResourcesPlugin.PI_RESOURCES + "/strings")); //$NON-NLS-1$
- }
- }
-
public static void checkCanceled(IProgressMonitor monitor) {
if (monitor.isCanceled())
throw new OperationCanceledException();
@@ -111,13 +114,26 @@ public class Policy {
* Pre-pend the message with the current date and the name of the current thread.
*/
public static void debug(String message) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(new Date(System.currentTimeMillis()));
- buffer.append(" - ["); //$NON-NLS-1$
- buffer.append(Thread.currentThread().getName());
- buffer.append("] "); //$NON-NLS-1$
- buffer.append(message);
- System.out.println(buffer.toString());
+ StringBuilder output = new StringBuilder();
+ output.append(new Date(System.currentTimeMillis()));
+ output.append(" - ["); //$NON-NLS-1$
+ output.append(Thread.currentThread().getName());
+ output.append("] "); //$NON-NLS-1$
+ output.append(message);
+ System.out.println(output.toString());
+ }
+
+ /**
+ * Print a debug throwable to the console.
+ * Pre-pend the throwable with the current date and the name of the current thread.
+ */
+ public static void debug(Throwable t) {
+ StringWriter writer = new StringWriter();
+ t.printStackTrace(new PrintWriter(writer));
+ String str = writer.toString();
+ if (str.endsWith("\n")) //$NON-NLS-1$
+ str = str.substring(0, str.length() - 2);
+ Policy.debug(str);
}
public static void log(int severity, String message, Throwable t) {
diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java
index 4a92f4a7d..d3dbf4c36 100644
--- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java
+++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/resources/ResourcesPlugin.java
@@ -14,14 +14,16 @@
*******************************************************************************/
package org.eclipse.core.resources;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
import org.eclipse.core.internal.preferences.PreferencesService;
import org.eclipse.core.internal.resources.*;
import org.eclipse.core.internal.utils.Messages;
+import org.eclipse.core.internal.utils.Policy;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.jobs.IJobManager;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.osgi.service.debug.DebugOptions;
+import org.eclipse.osgi.service.debug.DebugOptionsListener;
import org.osgi.framework.*;
/**
@@ -334,6 +336,7 @@ public final class ResourcesPlugin extends Plugin {
private static Workspace workspace = null;
private ServiceRegistration<IWorkspace> workspaceRegistration;
+ private ServiceRegistration<DebugOptionsListener> debugRegistration;
/**
* Constructs an instance of this plug-in runtime class.
@@ -415,6 +418,11 @@ public final class ResourcesPlugin extends Plugin {
*/
public void stop(BundleContext context) throws Exception {
super.stop(context);
+
+ // unregister debug options listener
+ debugRegistration.unregister();
+ debugRegistration = null;
+
if (workspace == null)
return;
workspaceRegistration.unregister();
@@ -435,6 +443,12 @@ public final class ResourcesPlugin extends Plugin {
*/
public void start(BundleContext context) throws Exception {
super.start(context);
+
+ // register debug options listener
+ Hashtable<String, String> properties = new Hashtable<String, String>(2);
+ properties.put(DebugOptions.LISTENER_SYMBOLICNAME, PI_RESOURCES);
+ debugRegistration = context.registerService(DebugOptionsListener.class, Policy.RESOURCES_DEBUG_OPTIONS_LISTENER, properties);
+
if (!new LocalMetaArea().hasSavedWorkspace()) {
constructWorkspace();
}

Back to the top