From 11e54329c790f81fd71053fe5bd069fba81079f7 Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Mon, 19 Jul 2010 13:17:37 +0400 Subject: [PATCH 1/4] write exceptions to log instead of printing to console --- .../references/PrefixReferenceProvider.java | 5 ++- .../relaxNG/validation/MessageViewHelper.java | 31 ++++++++++--------- .../plugins/relaxNG/validation/RngParser.java | 12 ++++--- .../validation/XmlInstanceValidator.java | 8 +++-- .../plugins/relaxNG/HighlightingTestBase.java | 2 +- 5 files changed, 36 insertions(+), 22 deletions(-) diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java index ee5354b8515f..6252728de819 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/references/PrefixReferenceProvider.java @@ -22,6 +22,7 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo; import com.intellij.codeInsight.daemon.impl.analysis.CreateNSDeclarationIntentionFix; import com.intellij.codeInsight.daemon.impl.quickfix.QuickFixAction; import com.intellij.lang.xml.XMLLanguage; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; @@ -44,6 +45,8 @@ import org.jetbrains.annotations.Nullable; * Date: 24.07.2007 */ public class PrefixReferenceProvider extends PsiReferenceProviderBase { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.references.PrefixReferenceProvider"); + @NotNull public PsiReference[] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { final XmlAttributeValue value = (XmlAttributeValue)element; @@ -102,7 +105,7 @@ public class PrefixReferenceProvider extends PsiReferenceProviderBase { QuickFixAction.registerQuickFixAction(info, new CreateNSDeclarationIntentionFix(tag, reference.getCanonicalText())); } catch (Throwable e) { - e.printStackTrace(); + LOG.error(e); } } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java index a0af4a70dd45..a2baae294ffc 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/MessageViewHelper.java @@ -17,7 +17,9 @@ package org.intellij.plugins.relaxNG.validation; import com.intellij.ide.errorTreeView.NewErrorTreeViewPanel; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.command.CommandProcessor; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Messages; import com.intellij.openapi.util.Key; @@ -33,7 +35,6 @@ import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.helpers.DefaultHandler; -import javax.swing.*; import java.net.MalformedURLException; import java.net.URL; import java.util.Set; @@ -44,6 +45,8 @@ import java.util.Set; * Date: 19.11.2007 */ public class MessageViewHelper { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.MessageViewHelper"); + private final Project myProject; private final Set myErrors = new THashSet(); @@ -91,23 +94,23 @@ public class MessageViewHelper { try { file = VfsUtil.findFileByURL(new URL(systemId)); } catch (MalformedURLException e) { - System.err.println("systemId = " + systemId); - e.printStackTrace(); + LOG.warn("systemId = " + systemId); + LOG.error(e); } } final VirtualFile file1 = file; - SwingUtilities.invokeLater( - new Runnable() { - public void run() { - myErrorsView.addMessage( - warning ? MessageCategory.WARNING : MessageCategory.ERROR, - new String[]{ ex.getLocalizedMessage() }, - file1, - ex.getLineNumber() - 1, - ex.getColumnNumber() - 1, null); - } - } + ApplicationManager.getApplication().invokeLater( + new Runnable() { + public void run() { + myErrorsView.addMessage( + warning ? MessageCategory.WARNING : MessageCategory.ERROR, + new String[]{ex.getLocalizedMessage()}, + file1, + ex.getLineNumber() - 1, + ex.getColumnNumber() - 1, null); + } + } ); } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java index 2e41399879ca..232938704cd1 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/RngParser.java @@ -16,6 +16,7 @@ package org.intellij.plugins.relaxNG.validation; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.util.Key; import com.intellij.openapi.util.SystemInfo; @@ -62,12 +63,15 @@ import java.io.StringReader; * Date: 19.07.2007 */ public class RngParser { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.RngParser"); + static final Key> SCHEMA_KEY = Key.create("SCHEMA"); static final Key> PATTERN_KEY = Key.create("PATTERN"); public static final DefaultHandler DEFAULT_HANDLER = new DefaultHandler() { public void error(SAXParseException e) throws SAXException { - System.out.println("e.getMessage() = " + e.getMessage() + " [" + e.getSystemId() + "]"); + LOG.info("e.getMessage() = " + e.getMessage() + " [" + e.getSystemId() + "]"); + LOG.info(e); } }; @@ -90,9 +94,9 @@ public class RngParser { return (DPattern)p.parse(checking ? new CheckingSchemaBuilder(sb, eh) : sb); } catch (BuildException e) { - e.printStackTrace(); + LOG.info(e); } catch (IllegalSchemaException e) { - System.out.println("invalid schema: " + file.getVirtualFile().getPresentableUrl()); + LOG.info("invalid schema: " + file.getVirtualFile().getPresentableUrl()); } return null; } @@ -166,7 +170,7 @@ public class RngParser { return Result.createSingleDependency(schema, descriptorFile); } } catch (Exception e) { - e.printStackTrace(); + LOG.info(e); return Result.createSingleDependency(null, descriptorFile); } } diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java index 2956996170f3..02a835452697 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/validation/XmlInstanceValidator.java @@ -17,6 +17,7 @@ package org.intellij.plugins.relaxNG.validation; import com.intellij.codeInsight.daemon.Validator; +import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.progress.ProcessCanceledException; import com.intellij.psi.PsiDocumentManager; @@ -40,6 +41,7 @@ import org.xml.sax.SAXParseException; * Date: 30.07.2007 */ public class XmlInstanceValidator { + private static final Logger LOG = Logger.getInstance("#org.intellij.plugins.relaxNG.validation.MessageViewHelper"); public static void doValidation(@NotNull final XmlDocument doc, final Validator.ValidationHost host, final XmlFile descriptorFile) { try { @@ -61,9 +63,11 @@ public class XmlInstanceValidator { doc.accept(new Psi2SaxAdapter(handler)); } catch (ProcessCanceledException e) { - throw e; + LOG.error(e); + } catch (RuntimeException e) { + LOG.error(e); } catch (Exception e) { - e.printStackTrace(); + LOG.info(e); } } diff --git a/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java b/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java index a25cff996b95..08dc74d42a96 100644 --- a/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java +++ b/plugins/relaxng/test/org/intellij/plugins/relaxNG/HighlightingTestBase.java @@ -85,7 +85,7 @@ public abstract class HighlightingTestBase extends TestCase implements IdeaCodeI } }); } catch (IOException e) { - e.printStackTrace(); + throw new RuntimeException(e); } } From dccb1f8f664ac81e104e9b5e358c16cbf6090bb0 Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Mon, 19 Jul 2010 13:19:02 +0400 Subject: [PATCH 2/4] idea config cleanup --- java/compiler/impl/compiler-impl.iml | 2 -- .../intellij/roots/libraries/LibraryTest.java | 2 +- .../roots/impl/libraries/LibraryImpl.java | 2 +- plugins/cvs/cvs-core/cvs-core.iml | 1 - plugins/git4idea/git4idea.iml | 1 - plugins/groovy/jetgroovy.iml | 2 -- plugins/maven/facade-api/maven-facade-api.iml | 2 -- .../maven/facade-impl/maven-facade-impl.iml | 28 ------------------- plugins/relaxng/relaxng.iml | 7 ----- plugins/svn4idea/svn4idea-tests.iml | 3 -- plugins/svn4idea/svn4idea.iml | 5 ---- 11 files changed, 2 insertions(+), 53 deletions(-) diff --git a/java/compiler/impl/compiler-impl.iml b/java/compiler/impl/compiler-impl.iml index 4f7473c9ff2a..381f3496886b 100644 --- a/java/compiler/impl/compiler-impl.iml +++ b/java/compiler/impl/compiler-impl.iml @@ -23,8 +23,6 @@ - - diff --git a/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java b/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java index a9578c24654e..b1bbd7a29e74 100644 --- a/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java +++ b/java/java-tests/testSrc/com/intellij/roots/libraries/LibraryTest.java @@ -47,7 +47,7 @@ public class LibraryTest extends IdeaTestCase { final Element element = new Element("root"); library.writeExternal(element); - assertEquals("", + assertEquals("", new XMLOutputter().outputString(element)); ApplicationManager.getApplication().runWriteAction(new Runnable() { diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java index 091ccf348d86..762e7b6bd738 100644 --- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java +++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/libraries/LibraryImpl.java @@ -277,7 +277,7 @@ public class LibraryImpl implements LibraryEx.ModifiableModelEx, LibraryEx { if (roots.size() == 0 && rootType.skipWriteIfEmpty()) continue; //compatibility iml/ipr final Element rootTypeElement = new Element(rootType.name()); roots.writeExternal(rootTypeElement, ROOT_PATH_ELEMENT); - element.addContent(rootTypeElement); + if (rootTypeElement.getAttributes().size() > 0 || rootTypeElement.getContent().size() > 0) element.addContent(rootTypeElement); } List urls = new ArrayList(myJarDirectories.keySet()); Collections.sort(urls, new Comparator() { diff --git a/plugins/cvs/cvs-core/cvs-core.iml b/plugins/cvs/cvs-core/cvs-core.iml index 53189febbd11..f170b4099106 100644 --- a/plugins/cvs/cvs-core/cvs-core.iml +++ b/plugins/cvs/cvs-core/cvs-core.iml @@ -15,7 +15,6 @@ - diff --git a/plugins/git4idea/git4idea.iml b/plugins/git4idea/git4idea.iml index aa21265058b8..5fa1b17970c1 100644 --- a/plugins/git4idea/git4idea.iml +++ b/plugins/git4idea/git4idea.iml @@ -16,7 +16,6 @@ - diff --git a/plugins/groovy/jetgroovy.iml b/plugins/groovy/jetgroovy.iml index 3b210de157c4..3ead47ab4a1e 100644 --- a/plugins/groovy/jetgroovy.iml +++ b/plugins/groovy/jetgroovy.iml @@ -26,8 +26,6 @@ - - diff --git a/plugins/maven/facade-api/maven-facade-api.iml b/plugins/maven/facade-api/maven-facade-api.iml index 8ba63b8dc7db..56173f227d95 100644 --- a/plugins/maven/facade-api/maven-facade-api.iml +++ b/plugins/maven/facade-api/maven-facade-api.iml @@ -14,8 +14,6 @@ - - diff --git a/plugins/maven/facade-impl/maven-facade-impl.iml b/plugins/maven/facade-impl/maven-facade-impl.iml index 9240cd8ba91c..ae61f67a346f 100644 --- a/plugins/maven/facade-impl/maven-facade-impl.iml +++ b/plugins/maven/facade-impl/maven-facade-impl.iml @@ -16,8 +16,6 @@ - - @@ -25,8 +23,6 @@ - - @@ -34,8 +30,6 @@ - - @@ -43,8 +37,6 @@ - - @@ -52,8 +44,6 @@ - - @@ -61,8 +51,6 @@ - - @@ -70,8 +58,6 @@ - - @@ -79,8 +65,6 @@ - - @@ -88,8 +72,6 @@ - - @@ -97,8 +79,6 @@ - - @@ -106,8 +86,6 @@ - - @@ -115,8 +93,6 @@ - - @@ -124,8 +100,6 @@ - - @@ -133,8 +107,6 @@ - - diff --git a/plugins/relaxng/relaxng.iml b/plugins/relaxng/relaxng.iml index d7d35d40c904..6ff34b95fc39 100644 --- a/plugins/relaxng/relaxng.iml +++ b/plugins/relaxng/relaxng.iml @@ -18,7 +18,6 @@ - @@ -29,8 +28,6 @@ - - @@ -38,8 +35,6 @@ - - @@ -47,8 +42,6 @@ - - diff --git a/plugins/svn4idea/svn4idea-tests.iml b/plugins/svn4idea/svn4idea-tests.iml index 798757278775..5039b6b4a9f5 100644 --- a/plugins/svn4idea/svn4idea-tests.iml +++ b/plugins/svn4idea/svn4idea-tests.iml @@ -16,7 +16,6 @@ - @@ -30,8 +29,6 @@ - - diff --git a/plugins/svn4idea/svn4idea.iml b/plugins/svn4idea/svn4idea.iml index fd765b400568..e00b72d68d9c 100644 --- a/plugins/svn4idea/svn4idea.iml +++ b/plugins/svn4idea/svn4idea.iml @@ -22,7 +22,6 @@ - @@ -33,8 +32,6 @@ - - @@ -43,8 +40,6 @@ - - From db740a2bb8d209809a1cbeb443cceb26b82ac53d Mon Sep 17 00:00:00 2001 From: Eugene Kudelevsky Date: Mon, 19 Jul 2010 13:54:18 +0400 Subject: [PATCH 3/4] assertion message --- .../intellij/codeInsight/template/impl/TemplateState.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java index 720fb1d6a01d..10aaab15bc90 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateState.java @@ -70,6 +70,7 @@ public class TemplateState implements Disposable { private Editor myEditor; private TemplateImpl myTemplate; + private TemplateImpl myPrevTemplate; private TemplateSegments mySegments = null; private Map myPredefinedVariableValues; @@ -219,6 +220,7 @@ public class TemplateState implements Disposable { mySegments = null; } myTemplateRange = null; + myPrevTemplate = myTemplate; myTemplate = null; releaseEditor(); myTabStopHighlighters.clear(); @@ -271,6 +273,7 @@ public class TemplateState implements Disposable { myTemplateIndented = false; myCurrentVariableNumber = -1; mySegments = new TemplateSegments(myEditor); + myPrevTemplate = myTemplate; myTemplate = template; //myArgument = argument; myPredefinedVariableValues = predefinedVarValues; @@ -378,7 +381,7 @@ public class TemplateState implements Disposable { private void afterChangedUpdate() { if (isFinished()) return; - LOG.assertTrue(myTemplate != null); + LOG.assertTrue(myTemplate != null, myPrevTemplate != null ? myPrevTemplate.getKey() : "prev template is null"); if (myDocumentChanged) { if (myDocumentChangesTerminateTemplate || mySegments.isInvalid()) { final int oldIndex = myCurrentVariableNumber; From 2153bfcb7817b0c41855a72681ca6e285057722a Mon Sep 17 00:00:00 2001 From: Alexey Pegov Date: Mon, 19 Jul 2010 14:38:10 +0400 Subject: [PATCH 4/4] fix double slide project view on project open --- .../src/com/intellij/platform/PlatformProjectViewOpener.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java index a605677e93a7..16a574ef9f67 100644 --- a/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java +++ b/platform/lang-impl/src/com/intellij/platform/PlatformProjectViewOpener.java @@ -25,6 +25,7 @@ import com.intellij.openapi.application.ModalityState; import com.intellij.openapi.wm.ToolWindow; import com.intellij.openapi.wm.ToolWindowManager; import com.intellij.openapi.wm.ToolWindowId; +import com.intellij.openapi.wm.ToolWindowType; import org.jetbrains.annotations.NotNull; import javax.swing.*; @@ -43,7 +44,7 @@ public class PlatformProjectViewOpener implements DirectoryProjectConfigurator { public void run() { if (project.isDisposed()) return; final ToolWindow toolWindow = ToolWindowManager.getInstance(project).getToolWindow(ToolWindowId.PROJECT_VIEW); - if (toolWindow != null) { + if (toolWindow != null && toolWindow.getType() != ToolWindowType.SLIDING) { toolWindow.activate(null); } }