diff options
author | Szymon Ptaszkiewicz | 2014-08-12 12:47:14 +0000 |
---|---|---|
committer | Szymon Ptaszkiewicz | 2014-08-12 15:19:00 +0000 |
commit | e431954c755083fff59a8ae40b44e2fadbc2d621 (patch) | |
tree | 78446c41ce9907babde50ae815b77f5b127634a0 | |
parent | 5a1063511127619025e62f831c291931a4404af1 (diff) | |
download | eclipse.platform.resources-e431954c755083fff59a8ae40b44e2fadbc2d621.tar.gz eclipse.platform.resources-e431954c755083fff59a8ae40b44e2fadbc2d621.tar.xz eclipse.platform.resources-e431954c755083fff59a8ae40b44e2fadbc2d621.zip |
Bug 441585 - Add a new debug option to log resource change event notifications
4 files changed, 57 insertions, 2 deletions
diff --git a/bundles/org.eclipse.core.resources/.options b/bundles/org.eclipse.core.resources/.options index 6da427a8e..d8a2ced81 100644 --- a/bundles/org.eclipse.core.resources/.options +++ b/bundles/org.eclipse.core.resources/.options @@ -72,3 +72,6 @@ org.eclipse.core.resources/refresh=false # Prints debug information on resource content description org.eclipse.core.resources/contenttype=false org.eclipse.core.resources/contenttype/cache=false + +# Prints debug information about resource change event notifications +org.eclipse.core.resources/notifications=false diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java index 0a07bf242..9759c67c2 100644 --- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.java +++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/NotificationManager.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,6 +14,7 @@ package org.eclipse.core.internal.events; import java.util.*; import org.eclipse.core.internal.resources.*; import org.eclipse.core.internal.utils.Messages; +import org.eclipse.core.internal.utils.Policy; import org.eclipse.core.internal.watson.ElementTree; import org.eclipse.core.resources.*; import org.eclipse.core.runtime.*; @@ -288,6 +289,8 @@ public class NotificationManager implements IManager, ILifecycleListener { } public void run() throws Exception { + if (Policy.DEBUG_NOTIFICATIONS) + Policy.debug("Notifying " + listener + " about resource change event" + ((ResourceChangeEvent) event).toDebugString()); //$NON-NLS-1$ //$NON-NLS-2$ listener.resourceChanged(event); } }); diff --git a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceChangeEvent.java b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceChangeEvent.java index 4630adae8..4318698f5 100644 --- a/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceChangeEvent.java +++ b/bundles/org.eclipse.core.resources/src/org/eclipse/core/internal/events/ResourceChangeEvent.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2011 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 @@ -101,4 +101,51 @@ public class ResourceChangeEvent extends EventObject implements IResourceChangeE public void setDelta(IResourceDelta value) { delta = value; } + + public String toDebugString() { + StringBuilder output = new StringBuilder(); + output.append("\nType: ");//$NON-NLS-1$ + switch (type) { + case POST_CHANGE : + output.append("POST_CHANGE"); //$NON-NLS-1$ + break; + case PRE_CLOSE : + output.append("PRE_CLOSE"); //$NON-NLS-1$ + break; + case PRE_DELETE : + output.append("PRE_DELETE"); //$NON-NLS-1$ + break; + case PRE_BUILD : + output.append("PRE_BUILD"); //$NON-NLS-1$ + break; + case POST_BUILD : + output.append("POST_BUILD"); //$NON-NLS-1$ + break; + case PRE_REFRESH : + output.append("PRE_REFRESH"); //$NON-NLS-1$ + break; + default : + output.append("?"); //$NON-NLS-1$ + break; + } + output.append("\nBuild kind: "); //$NON-NLS-1$ + switch (trigger) { + case IncrementalProjectBuilder.FULL_BUILD : + output.append("FULL_BUILD"); //$NON-NLS-1$ + break; + case IncrementalProjectBuilder.AUTO_BUILD : + case IncrementalProjectBuilder.INCREMENTAL_BUILD : + output.append("INCREMENTAL_BUILD"); //$NON-NLS-1$ + break; + case IncrementalProjectBuilder.CLEAN_BUILD : + output.append("CLEAN_BUILD"); //$NON-NLS-1$ + break; + default : + output.append(trigger); + break; + } + output.append("\nResource: " + (resource == null ? "null" : resource)); //$NON-NLS-1$ //$NON-NLS-2$ + output.append("\nDelta:" + (delta == null ? " null" : ((ResourceDelta) delta).toDeepDebugString())); //$NON-NLS-1$ //$NON-NLS-2$ + return output.toString(); + } } 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 08f2735de..a929dcc66 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 @@ -38,6 +38,7 @@ public class Policy { 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_NOTIFICATIONS = DEBUG && options.getBooleanOption(ResourcesPlugin.PI_RESOURCES + "/notifications", 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$ @@ -78,6 +79,7 @@ public class Policy { public static boolean DEBUG_CONTENT_TYPE_CACHE = false; public static boolean DEBUG_HISTORY = false; public static boolean DEBUG_NATURES = false; + public static boolean DEBUG_NOTIFICATIONS = false; public static boolean DEBUG_PREFERENCES = false; // Get timing information for restoring data public static boolean DEBUG_RESTORE = false; |