From 52f7588809ddfd24269ebd931948b3f2726e4a7e Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sat, 26 Dec 2015 15:13:08 +0300 Subject: [PATCH] vcs: better logging in VcsDirtyScopeManager * Proper stringify AbstractVcs; * Better find the caller class avoiding internal delegation. --- .../vcs/changes/VcsDirtyScopeManagerImpl.java | 29 +++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java index 14c712c909d1..78ee87bd32d3 100644 --- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java +++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java @@ -19,6 +19,7 @@ import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vcs.AbstractVcs; import com.intellij.openapi.vcs.FilePath; import com.intellij.openapi.vcs.ProjectLevelVcsManager; @@ -85,7 +86,7 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr if ((! myProject.isOpen()) || myProject.isDisposed() || myVcsManager.getAllActiveVcss().length == 0) return; if (LOG.isDebugEnabled()) { - LOG.debug("everything dirty: " + ReflectionUtil.findCallerClass(2)); + LOG.debug("everything dirty: " + findFirstInterestingCallerClass()); } synchronized (LOCK) { @@ -139,7 +140,7 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr if (filesConverted.isEmpty() && dirsConverted.isEmpty()) return; if (LOG.isDebugEnabled()) { - LOG.debug("paths dirty: " + filesConverted + "; " + dirsConverted + "; " + ReflectionUtil.findCallerClass(3)); + LOG.debug("dirty files: " + toString(filesConverted) + "; dirty dirs: " + toString(dirsConverted) + "; " + findFirstInterestingCallerClass()); } boolean hasSomethingDirty; @@ -290,4 +291,28 @@ public class VcsDirtyScopeManagerImpl extends VcsDirtyScopeManager implements Pr } return result; } + + @NotNull + private static String toString(@NotNull final MultiMap filesByVcs) { + return StringUtil.join(filesByVcs.keySet(), new Function() { + @Override + public String fun(@NotNull AbstractVcs vcs) { + return vcs.getName() + ": " + StringUtil.join(filesByVcs.get(vcs), new Function() { + @Override + public String fun(@NotNull FilePath path) { + return path.getPath(); + } + }, "\n"); + } + }, "\n"); + } + + @Nullable + private static Class findFirstInterestingCallerClass() { + for (int i = 1; i <= 5; i++) { + Class clazz = ReflectionUtil.findCallerClass(i); + if (clazz == null || !clazz.getName().contains(VcsDirtyScopeManagerImpl.class.getName())) return clazz; + } + return null; + } }