diff --git a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java index 32f823cda947..72f442e407b4 100644 --- a/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/ExternalAnnotationsManagerImpl.java @@ -5,7 +5,7 @@ import com.google.common.annotations.VisibleForTesting; import com.intellij.CommonBundle; import com.intellij.ProjectTopics; import com.intellij.codeInsight.highlighting.HighlightManager; -import com.intellij.diagnostic.LogMessageEx; +import com.intellij.diagnostic.AttachmentFactory; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; import com.intellij.ide.highlighter.XmlFileType; @@ -727,8 +727,8 @@ public class ExternalAnnotationsManagerImpl extends ReadableExternalAnnotationsM @Override protected void duplicateError(@NotNull PsiFile file, @NotNull String externalName, @NotNull String text) { - String message = text + "; for signature: '" + externalName + "' in the file " + file.getVirtualFile().getPresentableUrl(); - LogMessageEx.error(LOG, message, file.getText()); + String message = text + "; for signature: '" + externalName + "' in the file " + file.getName(); + LOG.error(message, new Throwable(), AttachmentFactory.createAttachment(file.getVirtualFile())); } public static boolean areExternalAnnotationsApplicable(@NotNull PsiModifierListOwner owner) { diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java index 1277b07180ca..a9d31d7ed369 100644 --- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java +++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/config/QuickFixFactoryImpl.java @@ -24,7 +24,6 @@ import com.intellij.codeInspection.ex.EntryPointsManagerBase; import com.intellij.codeInspection.unusedSymbol.UnusedSymbolLocalInspectionBase; import com.intellij.codeInspection.util.SpecialAnnotationsUtil; import com.intellij.diagnostic.AttachmentFactory; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.lang.annotation.HighlightSeverity; import com.intellij.lang.java.request.CreateConstructorFromUsage; import com.intellij.lang.java.request.CreateMethodFromUsage; @@ -797,9 +796,9 @@ public class QuickFixFactoryImpl extends QuickFixFactory { if (oldStamp != document.getModificationStamp()) { String afterText = file.getText(); if (Comparing.strEqual(beforeText, afterText)) { - LOG.error( - LogMessageEx.createEvent("Import optimizer hasn't optimized any imports", file.getViewProvider().getVirtualFile().getPath(), - AttachmentFactory.createAttachment(file.getViewProvider().getVirtualFile()))); + LOG.error("Import optimizer hasn't optimized any imports", + new Throwable(file.getViewProvider().getVirtualFile().getPath()), + AttachmentFactory.createAttachment(file.getViewProvider().getVirtualFile())); } } }); diff --git a/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java b/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java index 64fa79e4d56e..fe10b0a3e222 100644 --- a/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java +++ b/java/java-impl/src/com/intellij/codeInsight/lookup/PsiTypeLookupItem.java @@ -4,14 +4,12 @@ package com.intellij.codeInsight.lookup; import com.intellij.codeInsight.completion.*; import com.intellij.codeInsight.editorActions.TabOutScopesTracker; import com.intellij.diagnostic.AttachmentFactory; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.editor.ScrollType; import com.intellij.openapi.util.ClassConditionKey; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.*; -import com.intellij.psi.impl.DebugUtil; import com.intellij.psi.impl.source.PostprocessReformattingAspect; import com.intellij.psi.impl.source.PsiClassReferenceType; import com.intellij.psi.util.PsiFormatUtil; @@ -296,17 +294,17 @@ public class PsiTypeLookupItem extends LookupItem implements TypedLookupItem { int tail = context.getTailOffset(); int newTail = JavaCompletionUtil.insertClassReference(aClass, file, startOffset, tail); if (newTail > context.getDocument().getTextLength() || newTail < 0) { - LOG.error(LogMessageEx.createEvent("Invalid offset after insertion ", - "offset=" + newTail + "\n" + - "start=" + startOffset + "\n" + - "tail=" + tail + "\n" + - "file.length=" + file.getTextLength() + "\n" + - "document=" + context.getDocument() + "\n" + - DebugUtil.currentStackTrace(), - AttachmentFactory.createAttachment(context.getDocument()))); + LOG.error("Invalid offset after insertion\n" + + "offset=" + newTail + "\n" + + "start=" + startOffset + "\n" + + "tail=" + tail + "\n" + + "file.length=" + file.getTextLength() + "\n" + + "document=" + context.getDocument() + "\n" + + new Throwable(), + AttachmentFactory.createAttachment(context.getDocument())); return; - } + context.setTailOffset(newTail); JavaCompletionUtil.shortenReference(file, context.getStartOffset()); PostprocessReformattingAspect.getInstance(context.getProject()).doPostponedFormatting(); diff --git a/java/java-impl/src/com/intellij/codeInspection/streamToLoop/StreamToLoopInspection.java b/java/java-impl/src/com/intellij/codeInspection/streamToLoop/StreamToLoopInspection.java index 6f6fc58af6ca..960199ed3001 100644 --- a/java/java-impl/src/com/intellij/codeInspection/streamToLoop/StreamToLoopInspection.java +++ b/java/java-impl/src/com/intellij/codeInspection/streamToLoop/StreamToLoopInspection.java @@ -6,7 +6,6 @@ import com.intellij.codeInspection.LocalQuickFix; import com.intellij.codeInspection.ProblemDescriptor; import com.intellij.codeInspection.ProblemsHolder; import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.lang.java.lexer.JavaLexer; import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.diagnostic.Logger; @@ -25,7 +24,6 @@ import com.intellij.psi.util.PsiTreeUtil; import com.intellij.psi.util.PsiUtil; import com.intellij.psi.util.RedundantCastUtil; import com.intellij.refactoring.util.RefactoringUtil; -import com.intellij.util.ExceptionUtil; import com.intellij.util.ObjectUtils; import com.intellij.util.containers.ContainerUtil; import com.siyeh.ig.callMatcher.CallMatcher; @@ -330,9 +328,7 @@ public class StreamToLoopInspection extends AbstractBaseJavaLocalInspectionTool } } catch (Exception ex) { - String text = terminalCall.getText(); - LOG.error(LogMessageEx.createEvent("Error converting Stream to loop", ExceptionUtil.getThrowableText(ex), - new Attachment("Stream_code.txt", text))); + LOG.error("Error converting Stream to loop", ex, new Attachment("Stream_code.txt", terminalCall.getText())); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionAssertions.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionAssertions.java index daaaf2d5587f..20ed8c64ead9 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionAssertions.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionAssertions.java @@ -1,23 +1,8 @@ -/* - * Copyright 2000-2014 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.completion; import com.intellij.codeInsight.lookup.Lookup; import com.intellij.codeInsight.lookup.LookupElement; -import com.intellij.diagnostic.LogEventException; import com.intellij.injected.editor.DocumentWindow; import com.intellij.injected.editor.EditorWindow; import com.intellij.lang.FileASTNode; @@ -86,10 +71,11 @@ class CompletionAssertions { message += "\nvirtualFile.class=" + virtualFile.getClass(); message += "\n" + DebugUtil.currentStackTrace(); - throw new LogEventException("Commit unsuccessful", message, - new Attachment(virtualFile.getPath() + "_file.txt", StringUtil.notNullize(fileText)), - createAstAttachment(psiFile, psiFile), - new Attachment("docText.txt", document.getText())); + throw new RuntimeExceptionWithAttachments( + "Commit unsuccessful", message, + new Attachment(virtualFile.getPath() + "_file.txt", StringUtil.notNullize(fileText)), + createAstAttachment(psiFile, psiFile), + new Attachment("docText.txt", document.getText())); } static void checkEditorValid(Editor editor) { @@ -131,22 +117,23 @@ class CompletionAssertions { PsiFile originalFile, PsiElement insertedElement) { PsiFile fileCopy = offsets.getFile(); if (insertedElement == null) { - throw new LogEventException("No element at insertion offset", - "offset=" + - offset + - "\n" + - DebugUtil.currentStackTrace(), - createFileTextAttachment(fileCopy, originalFile), - createAstAttachment(fileCopy, originalFile)); + throw new RuntimeExceptionWithAttachments( + "No element at insertion offset", + "offset=" + offset, + createFileTextAttachment(fileCopy, originalFile), + createAstAttachment(fileCopy, originalFile)); } final TextRange range = insertedElement.getTextRange(); CharSequence fileCopyText = fileCopy.getViewProvider().getContents(); if ((range.getEndOffset() > fileCopyText.length()) || !fileCopyText.subSequence(range.getStartOffset(), range.getEndOffset()).toString().equals(insertedElement.getText())) { - throw new LogEventException("Inconsistent completion tree", "range=" + range + "\n" + DebugUtil.currentStackTrace(), - createFileTextAttachment(fileCopy, originalFile), createAstAttachment(fileCopy, originalFile), - new Attachment("Element at caret.txt", insertedElement.getText())); + throw new RuntimeExceptionWithAttachments( + "Inconsistent completion tree", + "range=" + range, + createFileTextAttachment(fileCopy, originalFile), + createAstAttachment(fileCopy, originalFile), + new Attachment("Element at caret.txt", insertedElement.getText())); } } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java index 2930583a53c0..00d9c7213050 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/completion/CompletionUtil.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.completion; @@ -20,11 +6,11 @@ import com.intellij.codeInsight.TailType; import com.intellij.codeInsight.lookup.Lookup; import com.intellij.codeInsight.lookup.LookupElement; import com.intellij.codeInsight.lookup.LookupValueWithPsiElement; -import com.intellij.diagnostic.LogEventException; import com.intellij.diagnostic.ThreadDumper; import com.intellij.featureStatistics.FeatureUsageTracker; import com.intellij.lang.Language; import com.intellij.openapi.diagnostic.Attachment; +import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments; import com.intellij.openapi.editor.Document; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.extensions.Extensions; @@ -36,7 +22,6 @@ import com.intellij.psi.PsiDocumentManager; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiFile; import com.intellij.psi.filters.TrueFilter; -import com.intellij.util.ExceptionUtil; import com.intellij.util.UnmodifiableIterator; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NonNls; @@ -286,10 +271,13 @@ public class CompletionUtil { } } - private LogEventException handleCME(ConcurrentModificationException e) { - final Attachment dump = new Attachment("threadDump.txt", ThreadDumper.dumpThreadsToString()); - return new LogEventException("Error while traversing lookup strings of " + element + " of " + element.getClass(), - ExceptionUtil.getThrowableText(e), dump); + private RuntimeException handleCME(ConcurrentModificationException cme) { + RuntimeExceptionWithAttachments ewa = new RuntimeExceptionWithAttachments( + "Error while traversing lookup strings of " + element + " of " + element.getClass(), + (String)null, + new Attachment("threadDump.txt", ThreadDumper.dumpThreadsToString())); + ewa.initCause(cme); + return ewa; } }; } diff --git a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/ExtendWordSelectionHandlerBase.java b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/ExtendWordSelectionHandlerBase.java index 712dd2127ca9..81ea83c8f338 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/editorActions/ExtendWordSelectionHandlerBase.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/editorActions/ExtendWordSelectionHandlerBase.java @@ -1,24 +1,10 @@ -/* - * Copyright 2000-2013 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.editorActions; -import com.intellij.diagnostic.LogEventException; import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments; import com.intellij.openapi.editor.Editor; import com.intellij.openapi.util.TextRange; import com.intellij.openapi.util.text.StringUtil; @@ -44,14 +30,12 @@ public abstract class ExtendWordSelectionHandlerBase implements ExtendWordSelect public List select(@NotNull PsiElement e, @NotNull CharSequence editorText, int cursorOffset, @NotNull Editor editor) { final TextRange originalRange = e.getTextRange(); if (originalRange.getEndOffset() > editorText.length()) { - throw new LogEventException("Invalid element range in " + getClass(), - "element=" + e + - "; range=" + originalRange + - "; text length=" + editorText.length() + - "; editor=" + editor + - "; committed=" + PsiDocumentManager.getInstance(e.getProject()).isCommitted(editor.getDocument()), - new Attachment("editor_text.txt", editorText.toString()), - new Attachment("psi_text.txt", e.getText())); + throw new RuntimeExceptionWithAttachments( + "Invalid element range in " + getClass(), + "element=" + e + "; range=" + originalRange + "; text length=" + editorText.length() + "; editor=" + editor + + "; committed=" + PsiDocumentManager.getInstance(e.getProject()).isCommitted(editor.getDocument()), + new Attachment("editor_text.txt", editorText.toString()), + new Attachment("psi_text.txt", e.getText())); } List ranges = expandToWholeLine(editorText, originalRange, true); diff --git a/platform/lang-impl/src/com/intellij/formatting/RangesAssert.java b/platform/lang-impl/src/com/intellij/formatting/RangesAssert.java index 159cbf25c7f2..e2bdd00e9d5b 100644 --- a/platform/lang-impl/src/com/intellij/formatting/RangesAssert.java +++ b/platform/lang-impl/src/com/intellij/formatting/RangesAssert.java @@ -1,21 +1,7 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.formatting; -import com.intellij.diagnostic.LogMessageEx; +import com.intellij.diagnostic.AttachmentFactory; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiFile; @@ -60,7 +46,6 @@ class RangesAssert { buffer.append('\n'); } - LogMessageEx.error(LOG, messageBuffer.toString(), buffer.toString()); + LOG.error(messageBuffer.toString(), new Throwable(), AttachmentFactory.createContext(buffer)); } - } \ No newline at end of file diff --git a/platform/lang-impl/src/com/intellij/formatting/engine/AlignmentHelper.java b/platform/lang-impl/src/com/intellij/formatting/engine/AlignmentHelper.java index bc8eadd606c7..54072c70a2bc 100644 --- a/platform/lang-impl/src/com/intellij/formatting/engine/AlignmentHelper.java +++ b/platform/lang-impl/src/com/intellij/formatting/engine/AlignmentHelper.java @@ -1,21 +1,7 @@ -/* - * Copyright 2000-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.formatting.engine; -import com.intellij.diagnostic.LogMessageEx; +import com.intellij.diagnostic.AttachmentFactory; import com.intellij.formatting.*; import com.intellij.lang.ASTNode; import com.intellij.lang.Language; @@ -57,9 +43,8 @@ public class AlignmentHelper { private static void reportAlignmentProcessingError(BlockAlignmentProcessor.Context context) { ASTNode node = context.targetBlock.getNode(); Language language = node != null ? node.getPsi().getLanguage() : null; - LogMessageEx.error(LOG, - (language != null ? language.getDisplayName() + ": " : "") + - "Can't align block " + context.targetBlock, context.document.getText()); + String message = (language != null ? language.getDisplayName() + ": " : "") + "Can't align block " + context.targetBlock; + LOG.error(message, new Throwable(), AttachmentFactory.createAttachment(context.document)); } public LeafBlockWrapper applyAlignment(final AlignmentImpl alignment, final LeafBlockWrapper currentBlock) { diff --git a/platform/lang-impl/src/com/intellij/internal/psiView/formattingblocks/BlockViewerPsiBasedTree.java b/platform/lang-impl/src/com/intellij/internal/psiView/formattingblocks/BlockViewerPsiBasedTree.java index eb8e3fde6474..0b46c51dbeab 100644 --- a/platform/lang-impl/src/com/intellij/internal/psiView/formattingblocks/BlockViewerPsiBasedTree.java +++ b/platform/lang-impl/src/com/intellij/internal/psiView/formattingblocks/BlockViewerPsiBasedTree.java @@ -1,23 +1,8 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.psiView.formattingblocks; import com.intellij.application.options.CodeStyle; import com.intellij.diagnostic.AttachmentFactory; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.formatting.ASTBlock; import com.intellij.formatting.Block; import com.intellij.formatting.FormattingModel; @@ -153,11 +138,9 @@ public class BlockViewerPsiBasedTree implements ViewerPsiBasedTree { BlockTreeNode blockNode = myPsiToBlockMap.get(rootPsi); if (blockNode == null) { - PsiViewerDialog.LOG.error(LogMessageEx - .createEvent("PsiViewer: rootNode not found", - "Current language: " + rootElement.getContainingFile().getLanguage(), - AttachmentFactory - .createAttachment(rootElement.getContainingFile().getOriginalFile().getVirtualFile()))); + PsiViewerDialog.LOG.error("PsiViewer: rootNode not found\nCurrent language: " + rootElement.getContainingFile().getLanguage(), + (Throwable)null, + AttachmentFactory.createAttachment(rootElement.getContainingFile().getOriginalFile().getVirtualFile())); blockNode = findBlockNode(rootPsi); } diff --git a/platform/lang-impl/src/com/intellij/platform/templates/TemplateModuleBuilder.java b/platform/lang-impl/src/com/intellij/platform/templates/TemplateModuleBuilder.java index c3c89563f2a0..cb43a2c0e751 100644 --- a/platform/lang-impl/src/com/intellij/platform/templates/TemplateModuleBuilder.java +++ b/platform/lang-impl/src/com/intellij/platform/templates/TemplateModuleBuilder.java @@ -2,7 +2,6 @@ package com.intellij.platform.templates; import com.intellij.application.options.CodeStyle; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.execution.RunManager; import com.intellij.execution.configurations.ModuleBasedConfiguration; import com.intellij.execution.configurations.RunConfiguration; @@ -240,8 +239,7 @@ public class TemplateModuleBuilder extends ModuleBuilder { reportBuilder.append("\n===========================================\n"); } - LOG.error(LogMessageEx.createEvent("Cannot decode files in template", "", - new Attachment("Files in template", reportBuilder.toString()))); + LOG.error("Cannot decode files in template", (Throwable)null, new Attachment("Files in template", reportBuilder.toString())); } } ExceptionConsumer consumer = new ExceptionConsumer(); diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java index fe83cc197b94..ad14bfaed3f3 100644 --- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java @@ -4,7 +4,6 @@ package com.intellij.openapi.application.impl; import com.intellij.BundleBase; import com.intellij.CommonBundle; import com.intellij.concurrency.JobScheduler; -import com.intellij.diagnostic.LogEventException; import com.intellij.diagnostic.PerformanceWatcher; import com.intellij.diagnostic.ThreadDumper; import com.intellij.execution.process.ProcessIOExecutorService; @@ -25,6 +24,7 @@ import com.intellij.openapi.components.impl.ServiceManagerImpl; import com.intellij.openapi.components.impl.stores.StoreUtil; import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.diagnostic.Logger; +import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments; import com.intellij.openapi.extensions.ExtensionPointName; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.progress.*; @@ -1103,15 +1103,16 @@ public class ApplicationImpl extends PlatformComponentManagerImpl implements App assertIsDispatchThread("Access is allowed from event dispatch thread only."); } - private void assertIsDispatchThread(@NotNull String message) { + private void assertIsDispatchThread(String message) { if (isDispatchThread()) return; - final Attachment dump = new Attachment("threadDump.txt", ThreadDumper.dumpThreadsToString()); - throw new LogEventException(message, - " EventQueue.isDispatchThread()="+EventQueue.isDispatchThread()+ - " isDispatchThread()="+isDispatchThread()+ - " Toolkit.getEventQueue()="+Toolkit.getDefaultToolkit().getSystemEventQueue()+ - " Current thread: " + describe(Thread.currentThread())+ - " SystemEventQueueThread: " + describe(getEventQueueThread()), dump); + throw new RuntimeExceptionWithAttachments( + message, + " EventQueue.isDispatchThread()=" + EventQueue.isDispatchThread() + + " isDispatchThread()=" + isDispatchThread() + + " Toolkit.getEventQueue()=" + Toolkit.getDefaultToolkit().getSystemEventQueue() + + " Current thread: " + describe(Thread.currentThread()) + + " SystemEventQueueThread: " + describe(getEventQueueThread()), + new Attachment("threadDump.txt", ThreadDumper.dumpThreadsToString())); } @Override diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java index 76310b572b66..b687cae07816 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java @@ -1,8 +1,8 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.ex.util; +import com.intellij.diagnostic.AttachmentFactory; import com.intellij.diagnostic.Dumpable; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.ide.ui.UISettings; import com.intellij.injected.editor.EditorWindow; import com.intellij.openapi.Disposable; @@ -169,11 +169,11 @@ public final class EditorUtil { CharSequence editorInfo = "editor's class: " + editor.getClass() + ", all soft wraps: " + editor.getSoftWrapModel().getSoftWrapsForRange(0, document.getTextLength()) + ", fold regions: " + Arrays.toString(editor.getFoldingModel().getAllFoldRegions()); - LogMessageEx.error(LOG, "Can't calculate last visual column", String.format( + LOG.error("Can't calculate last visual column", new Throwable(), AttachmentFactory.createContext(String.format( "Target visual line: %d, mapped logical line: %d, visual lines range for the mapped logical line: [%s]-[%s], soft wraps for " + "the target logical line: %s. Editor info: %s", line, resultLogLine, resVisStart, resVisEnd, softWraps, editorInfo - )); + ))); return resVisEnd.column; } @@ -276,9 +276,8 @@ public final class EditorUtil { else { documentInfo = "Text holder class: " + text.getClass(); } - LogMessageEx.error( - LOG, "detected incorrect offset -> column number calculation", - "start: " + start + ", given offset: " + offset+", given tab size: " + tabSize + ". "+documentInfo+ editorInfo); + LOG.error("detected incorrect offset -> column number calculation", new Throwable(), AttachmentFactory.createContext( + "start: " + start + ", given offset: " + offset + ", given tab size: " + tabSize + ". " + documentInfo + editorInfo)); } } diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretImpl.java index d5131798e8ef..c1a58ef5de84 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretImpl.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/CaretImpl.java @@ -1,8 +1,8 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl; +import com.intellij.diagnostic.AttachmentFactory; import com.intellij.diagnostic.Dumpable; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.openapi.actionSystem.IdeActions; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.diagnostic.Logger; @@ -136,13 +136,14 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable { int textEnd = Math.min(document.getTextLength() - 1, Math.max(offset, actualOffset) + 1); CharSequence text = document.getCharsSequence().subSequence(textStart, textEnd); int inverseOffset = myEditor.logicalPositionToOffset(logicalPosition); - LogMessageEx.error( - LOG, "caret moved to wrong offset. Please submit a dedicated ticket and attach current editor's text to it.", - "Requested: offset=" + offset + ", logical position='" + logicalPosition + "' but actual: offset=" + - actualOffset + ", logical position='" + myLogicalCaret + "' (" + positionByOffsetAfterMove + "). " + myEditor.dumpState() + - "\ninterested text [" + textStart + ";" + textEnd + "): '" + text + "'\n debug trace: " + debugBuffer + - "\nLogical position -> offset ('" + logicalPosition + "'->'" + inverseOffset + "')" - ); + LOG.error( + "caret moved to wrong offset. Please submit a dedicated ticket and attach current editor's text to it.", + new Throwable(), + AttachmentFactory.createContext( + "Requested: offset=" + offset + ", logical position='" + logicalPosition + "' but actual: offset=" + + actualOffset + ", logical position='" + myLogicalCaret + "' (" + positionByOffsetAfterMove + "). " + myEditor.dumpState() + + "\ninterested text [" + textStart + ";" + textEnd + "): '" + text + "'\n debug trace: " + debugBuffer + + "\nLogical position -> offset ('" + logicalPosition + "'->'" + inverseOffset + "')")); } if (event != null) { myEditor.getCaretModel().fireCaretPositionChanged(event); @@ -169,7 +170,7 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable { return; } if (myReportCaretMoves) { - LogMessageEx.error(LOG, "Unexpected caret move request"); + LOG.error("Unexpected caret move request", new Throwable()); } if (!myEditor.isStickySelection() && !myEditor.getDocument().isInEventsHandling()) { CopyPasteManager.getInstance().stopKillRings(); @@ -474,9 +475,10 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable { } } else { - LogMessageEx.error(LOG, "Invalid editor dimension mapping", "Expected to map visual position '" + - visualPosition + "' to offset " + newOffset + " but got the following: -> logical position '" + - logicalPosition + "'; -> offset " + tmpOffset + ". State: " + myEditor.dumpState()); + LOG.error("Invalid editor dimension mapping", new Throwable(), AttachmentFactory.createContext( + "Expected to map visual position '" + + visualPosition + "' to offset " + newOffset + " but got the following: -> logical position '" + + logicalPosition + "'; -> offset " + tmpOffset + ". State: " + myEditor.dumpState())); } } } @@ -540,7 +542,7 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable { return; } if (myReportCaretMoves) { - LogMessageEx.error(LOG, "Unexpected caret move request"); + LOG.error("Unexpected caret move request"); } if (!myEditor.isStickySelection() && !myEditor.getDocument().isInEventsHandling() && !pos.equals(myVisibleCaret)) { CopyPasteManager.getInstance().stopKillRings(); @@ -606,7 +608,7 @@ public class CaretImpl extends UserDataHolderBase implements Caret, Dumpable { return null; } if (myReportCaretMoves) { - LogMessageEx.error(LOG, "Unexpected caret move request"); + LOG.error("Unexpected caret move request"); } if (!myEditor.isStickySelection() && !myEditor.getDocument().isInEventsHandling() && !pos.equals(myLogicalCaret)) { CopyPasteManager.getInstance().stopKillRings(); diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java index b73459ea49a4..63fea7055e62 100644 --- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java +++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/softwrap/mapping/SoftWrapApplianceManager.java @@ -1,22 +1,8 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.openapi.editor.impl.softwrap.mapping; +import com.intellij.diagnostic.AttachmentFactory; import com.intellij.diagnostic.Dumpable; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.openapi.diagnostic.Attachment; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.*; @@ -228,7 +214,8 @@ public class SoftWrapApplianceManager implements Dumpable { LOG.error("Soft wrapping is not supported for documents with non-standard line endings. File: " + myEditor.getVirtualFile()); } if (myInProgress) { - LogMessageEx.error(LOG, "Detected race condition at soft wraps recalculation", myEditor.dumpState(), event.toString()); + LOG.error("Detected race condition at soft wraps recalculation", new Throwable(), + AttachmentFactory.createContext(myEditor.dumpState(), event)); } myInProgress = true; try { @@ -482,9 +469,9 @@ public class SoftWrapApplianceManager implements Dumpable { int startOffset = myContext.currentPosition.offset; while (myContext.currentPosition.offset < myContext.tokenEndOffset) { if (counter++ > limit) { - LogMessageEx.error(LOG, "Cycled soft wraps recalculation detected", String.format( + LOG.error("Cycled soft wraps recalculation detected", new Throwable(), AttachmentFactory.createContext(String.format( "Start recalculation offset: %d, visible area width: %d, calculation context: %s, editor info: %s", - startOffset, myVisibleAreaWidth, myContext, myEditor.dumpState())); + startOffset, myVisibleAreaWidth, myContext, myEditor.dumpState()))); while (myContext.currentPosition.offset < myContext.tokenEndOffset) { int c = Character.codePointAt(myContext.text, myContext.currentPosition.offset); if (c == '\n') { diff --git a/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java b/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java index 1624f9c8dcdb..335c6ec6e136 100644 --- a/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java +++ b/platform/testRunner/src/com/intellij/execution/testframework/export/ExportTestResultsAction.java @@ -1,21 +1,6 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.execution.testframework.export; -import com.intellij.diagnostic.LogMessageEx; import com.intellij.execution.ExecutionBundle; import com.intellij.execution.configurations.RunConfiguration; import com.intellij.execution.testframework.TestFrameworkRunningModel; @@ -38,7 +23,6 @@ import com.intellij.openapi.vfs.LocalFileSystem; import com.intellij.openapi.vfs.VfsUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.wm.ToolWindowManager; -import com.intellij.util.ExceptionUtil; import com.intellij.util.PathUtil; import com.intellij.util.io.URLUtil; import org.jetbrains.annotations.NotNull; @@ -150,15 +134,18 @@ public class ExportTestResultsAction extends DumbAwareAction { return; } catch (RuntimeException ex) { - ExportTestResultsConfiguration c = new ExportTestResultsConfiguration(); - c.setExportFormat(ExportTestResultsConfiguration.ExportFormat.Xml); - c.setOpenResults(false); + String xml = null; try { - String xml = getOutputText(c); - LOG.error(LogMessageEx.createEvent("Failed to export test results", ExceptionUtil.getThrowableText(ex), null, null, - new Attachment("dump.xml", xml))); + ExportTestResultsConfiguration c = new ExportTestResultsConfiguration(); + c.setExportFormat(ExportTestResultsConfiguration.ExportFormat.Xml); + c.setOpenResults(false); + xml = getOutputText(c); } - catch (Throwable ignored) { + catch (Throwable ignored) { } + if (xml != null) { + LOG.error("Failed to export test results", ex, new Attachment("dump.xml", xml)); + } + else { LOG.error("Failed to export test results", ex); } return; diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java index 52cb8479f076..6c1ca3cb6d2f 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/refactoring/introduce/GrIntroduceHandlerBase.java @@ -2,7 +2,7 @@ package org.jetbrains.plugins.groovy.refactoring.introduce; import com.intellij.codeInsight.highlighting.HighlightManager; -import com.intellij.diagnostic.LogMessageEx; +import com.intellij.diagnostic.AttachmentFactory; import com.intellij.lang.LanguageRefactoringSupport; import com.intellij.lang.refactoring.RefactoringSupportProvider; import com.intellij.openapi.actionSystem.DataContext; @@ -683,7 +683,7 @@ public abstract class GrIntroduceHandlerBase