From fe4d96c66c05cd58759c5dad0d6f679ea52ea544 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Fri, 18 Mar 2005 18:42:02 +0300 Subject: [PATCH] compiler extra logging --- .../intellij/compiler/impl/CompileDriver.java | 28 +++++++++- .../compiler/impl/TimestampCache.java | 40 +++++++++++++ .../javaCompiler/BackendCompilerWrapper.java | 20 +++++-- .../impl/javaCompiler/JavaCompiler.java | 5 ++ .../debugger/ui/impl/DebuggerTreeBase.java | 56 +++++++++++-------- 5 files changed, 122 insertions(+), 27 deletions(-) diff --git a/source/com/intellij/compiler/impl/CompileDriver.java b/source/com/intellij/compiler/impl/CompileDriver.java index f8e18d269395..0b30f4c7c146 100644 --- a/source/com/intellij/compiler/impl/CompileDriver.java +++ b/source/com/intellij/compiler/impl/CompileDriver.java @@ -257,7 +257,17 @@ public class CompileDriver { synchronized (CompilerManager.getInstance(myProject)) { ProgressManager.getInstance().runProcess(new Runnable() { public void run() { - doCompile(compileContext, isRebuild, forceCompile, callback, checkCachesVersion); + try { + if (LOG.isDebugEnabled()) { + LOG.debug("COMPILATION STARTED"); + } + doCompile(compileContext, isRebuild, forceCompile, callback, checkCachesVersion); + } + finally { + if (LOG.isDebugEnabled()) { + LOG.debug("COMPILATION FINISHED"); + } + } } }, compileContext.getProgressIndicator()); } @@ -838,7 +848,13 @@ public class CompileDriver { if (cache.isDirty()) { context.getProgressIndicator().setText("Saving caches..."); if (cache.isDirty()) { + if (LOG.isDebugEnabled()) { + LOG.debug("--Saving translating cache for compiler " + compiler.getDescription()); + } cache.save(); + if (LOG.isDebugEnabled()) { + LOG.debug("--Done"); + } } } context.getProgressIndicator().popState(); @@ -936,6 +952,9 @@ public class CompileDriver { public void run() { context.getProgressIndicator().setText("Updating caches..."); final FileTypeManager typeManager = FileTypeManager.getInstance(); + if (LOG.isDebugEnabled()) { + LOG.debug("Updating internal caches: successfully compiled " + successfullyCompiled.length + " files; toRecompile: " + filesToRecompile.length + " files"); + } for (int idx = 0; idx < successfullyCompiled.length; idx++) { final TranslatingCompiler.OutputItem item = successfullyCompiled[idx]; final String outputPath = item.getOutputPath(); @@ -953,6 +972,9 @@ public class CompileDriver { else { className = null; } + if (LOG.isDebugEnabled()) { + LOG.debug("Putting: [outputPath, className, sourceFile] = [" + outputPath + ";" + className + ";" + sourceFile.getPresentableUrl() + "]"); + } cache.update(outputPath, className, sourceFile); } for (int idx = 0; idx < filesToRecompile.length; idx++) { @@ -1019,6 +1041,10 @@ public class CompileDriver { } } if (forceCompile || file.getTimeStamp() != cache.getSourceTimestamp(snapshot.getUrlByFile(file))) { + if (LOG.isDebugEnabled()) { + final String url = snapshot.getUrlByFile(file); + LOG.debug("File is out-of-date: " + url + "; current timestamp = " + file.getTimeStamp() + "; stored timestamp = " + cache.getSourceTimestamp(url)); + } toCompile.add(file); } } diff --git a/source/com/intellij/compiler/impl/TimestampCache.java b/source/com/intellij/compiler/impl/TimestampCache.java index 6a3b64b1293e..f80fff09eafd 100644 --- a/source/com/intellij/compiler/impl/TimestampCache.java +++ b/source/com/intellij/compiler/impl/TimestampCache.java @@ -20,6 +20,9 @@ public class TimestampCache extends StateCache { public void update(String url, Long state) { LOG.assertTrue(state != null); + if (LOG.isDebugEnabled()) { + LOG.debug("TimestampCache.update: " + url + "; " + state); + } super.update(url, state); } @@ -30,4 +33,41 @@ public class TimestampCache extends StateCache { public void write(Long aLong, DataOutputStream stream) throws IOException { stream.writeLong(aLong.longValue()); } + + protected boolean load() { + final boolean notInitialized = (myMap == null); + if (LOG.isDebugEnabled() && notInitialized) { + LOG.debug("TimestampCache.load"); + } + try { + return super.load(); + } + finally { + if (LOG.isDebugEnabled() && notInitialized) { + LOG.debug("TimestampCache.loaded: " + (myMap != null? myMap.size() + " items" : "empty map")); + } + } + } + + public void save() { + if (LOG.isDebugEnabled() && myMap != null) { + LOG.debug("TimestampCache.save"); + } + super.save(); + } + + public boolean wipe() { + if (LOG.isDebugEnabled()) { + LOG.debug("TimestampCache.wipe"); + } + return super.wipe(); + } + + public void remove(final String url) { + if (LOG.isDebugEnabled()) { + LOG.debug("TimestampCache.remove: " + url); + } + super.remove(url); + } + } diff --git a/source/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java b/source/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java index 0cb66c22f4a2..ff7c726b7be4 100644 --- a/source/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java +++ b/source/com/intellij/compiler/impl/javaCompiler/BackendCompilerWrapper.java @@ -469,7 +469,11 @@ class BackendCompilerWrapper { final String outputDirPath = outputDir.replace(File.separatorChar, '/'); for (int idx = 0; idx < sourceRoots.length; idx++) { final VirtualFile root = sourceRoots[idx]; - buildOutputItemsList(outputDirPath, root, typeManager, compiledWithErrors, root, myProjectFileIndex.getPackageNameByDirectory(root)); + final String packagePrefix = myProjectFileIndex.getPackageNameByDirectory(root); + if (LOG.isDebugEnabled()) { + LOG.debug("Building output items for " + root.getPresentableUrl() + "; output dir = " + outputDirPath + "; packagePrefix = \"" + packagePrefix + "\""); + } + buildOutputItemsList(outputDirPath, root, typeManager, compiledWithErrors, root, packagePrefix); } } }); @@ -605,9 +609,9 @@ class BackendCompilerWrapper { } private void updateOutputItemsList(final String outputDir, VirtualFile javaFile, Set compiledWithErrors, VirtualFile sourceRoot, final String packagePrefix) { - String name = javaFile.getName(); - if (myFileNameToSourceMap.containsKey(name)) { - Set> paths = myFileNameToSourceMap.get(name); + final String javaFileName = javaFile.getName(); + if (myFileNameToSourceMap.containsKey(javaFileName)) { + Set> paths = myFileNameToSourceMap.get(javaFileName); if (paths != null && paths.size() > 0) { final String prefix = packagePrefix != null && packagePrefix.length() > 0? packagePrefix.replace('.', '/') + "/" : ""; @@ -621,10 +625,18 @@ class BackendCompilerWrapper { final Pair realLocation = moveToRealLocation(outputDir, outputPath, javaFile); if (realLocation != null) { myOutputItems.add(new OutputItemImpl(realLocation.getFirst(), realLocation.getSecond(), javaFile)); + if (LOG.isDebugEnabled()) { + LOG.debug("Added output item: [outputDir; outputPath; sourceFile] = [" + realLocation.getFirst() + "; " + realLocation.getSecond() + "; " + javaFile.getPresentableUrl() + "]"); + } if (!compiledWithErrors.contains(javaFile)) { mySuccesfullyCompiledJavaFiles.add(javaFile); } } + else { + if (LOG.isDebugEnabled()) { + LOG.debug("Failed to move to real location: " + outputPath + "; from " + outputDir); + } + } } } } diff --git a/source/com/intellij/compiler/impl/javaCompiler/JavaCompiler.java b/source/com/intellij/compiler/impl/javaCompiler/JavaCompiler.java index 1d47c737d51e..0fd3ee7bb267 100644 --- a/source/com/intellij/compiler/impl/javaCompiler/JavaCompiler.java +++ b/source/com/intellij/compiler/impl/javaCompiler/JavaCompiler.java @@ -17,8 +17,10 @@ import com.intellij.openapi.fileTypes.FileTypeManager; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.openapi.diagnostic.Logger; public class JavaCompiler implements TranslatingCompiler { + private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.impl.javaCompiler.JavaCompiler"); private Project myProject; private BackendCompiler JAVAC_BACKEND; private BackendCompiler JIKES_BACKEND; @@ -49,6 +51,9 @@ public class JavaCompiler implements TranslatingCompiler { context.addMessage(CompilerMessageCategory.ERROR, e.getMessage(), null, -1, -1); } catch (CacheCorruptedException e) { + if (LOG.isDebugEnabled()) { + LOG.debug(e); + } context.requestRebuildNextTime(e.getMessage()); } diff --git a/source/com/intellij/debugger/ui/impl/DebuggerTreeBase.java b/source/com/intellij/debugger/ui/impl/DebuggerTreeBase.java index dcb54f89af33..d7d9826a4f48 100644 --- a/source/com/intellij/debugger/ui/impl/DebuggerTreeBase.java +++ b/source/com/intellij/debugger/ui/impl/DebuggerTreeBase.java @@ -19,6 +19,7 @@ import org.jdom.Element; import org.jdom.output.XMLOutputter; import javax.swing.*; +import javax.swing.border.Border; import javax.swing.tree.TreeModel; import javax.swing.tree.TreePath; import java.awt.*; @@ -140,34 +141,38 @@ public class DebuggerTreeBase extends Tree { public JComponent createToolTip(MouseEvent e) { DebuggerTreeNodeImpl node = getNodeToShowTip(e); - if (node == null) return null; + if (node == null) { + return null; + } - if(myCurrentTooltip != null && - myCurrentTooltip.isShowing() && - myCurrentTooltipNode == node) return myCurrentTooltip; + if(myCurrentTooltip != null && myCurrentTooltip.isShowing() && myCurrentTooltipNode == node) { + return myCurrentTooltip; + } myCurrentTooltipNode = node; - JToolTip toolTip = new JToolTip(); - toolTip.setLayout(new BorderLayout()); + final String toolTipText = getTipText(node); + if(toolTipText == null) { + return null; + } - String toolTipText = getTipText(node); - if(toolTipText == null) return null; - - JScrollPane scrollPane = new JScrollPane(createTipContent(toolTipText)); + final JComponent tipContent = createTipContent(toolTipText); + final JScrollPane scrollPane = new JScrollPane(tipContent); scrollPane.setBorder(null); scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); - toolTip.add(scrollPane); - JComponent tipContent = createTipContent(toolTipText); + final JToolTip toolTip = new JToolTip(); + toolTip.setLayout(new BorderLayout()); + toolTip.add(scrollPane, BorderLayout.CENTER); + Rectangle tipRectangle = getTipRectangle(e, tipContent.getPreferredSize()); - if(toolTip.getBorder() != null) { - Insets borderInsets = toolTip.getBorder().getBorderInsets(this); - tipRectangle.setSize(tipRectangle.width + borderInsets.left + borderInsets.right, - tipRectangle.height + borderInsets.top + borderInsets.bottom); + final Border tooltipBorder = toolTip.getBorder(); + if(tooltipBorder != null) { + final Insets borderInsets = tooltipBorder.getBorderInsets(this); + tipRectangle.setSize(tipRectangle.width + borderInsets.left + borderInsets.right, tipRectangle.height + borderInsets.top + borderInsets.bottom); } - Dimension tipSize = new Dimension(tipRectangle.getSize()); + final Dimension tipSize = new Dimension(tipRectangle.getSize()); if(tipRectangle.getWidth() < tipContent.getPreferredSize().getWidth()) { tipSize.height += scrollPane.getHorizontalScrollBar().getPreferredSize().height; @@ -215,7 +220,9 @@ public class DebuggerTreeBase extends Tree { TreePath path = getPathForLocation(event.getX(), event.getY()); if (path != null) { Object last = path.getLastPathComponent(); - if (last instanceof DebuggerTreeNodeImpl) return (DebuggerTreeNodeImpl)last; + if (last instanceof DebuggerTreeNodeImpl) { + return (DebuggerTreeNodeImpl)last; + } } return null; @@ -237,16 +244,21 @@ public class DebuggerTreeBase extends Tree { if(event.getY() > contentRect.y + contentRect.height / 2) { y = Math.max(contentRect.y, nodeBounds.y - tipContentSize.height - vgap); height = Math.min(tipContentSize.height, nodeBounds.y - contentRect.y - vgap); - } else { + } + else { y = nodeBounds.y + nodeBounds.height + vgap; height = Math.min(tipContentSize.height, contentRect.height - y); } - Dimension tipSize = new Dimension(width, height); + final Dimension tipSize = new Dimension(width, height); x = event.getX() - width / 2; - if(x < contentRect.x) x = contentRect.x; - if(x + width > contentRect.x + contentRect.width) x = contentRect.x + contentRect.width - width; + if(x < contentRect.x) { + x = contentRect.x; + } + if(x + width > contentRect.x + contentRect.width) { + x = contentRect.x + contentRect.width - width; + } return new Rectangle(new Point(x, y), tipSize); }