[project] migrating from deprecated logging API

This commit is contained in:
Roman Shevchenko
2018-05-30 10:44:49 +03:00
parent e10f08b8b9
commit 99db6052eb
19 changed files with 121 additions and 276 deletions
@@ -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) {
@@ -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()));
}
}
});
@@ -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();
@@ -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()));
}
}
@@ -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()));
}
}
@@ -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;
}
};
}
@@ -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<TextRange> 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<TextRange> ranges = expandToWholeLine(editorText, originalRange, true);
@@ -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));
}
}
@@ -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) {
@@ -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);
}
@@ -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();
@@ -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
@@ -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));
}
}
@@ -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();
@@ -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') {
@@ -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;
@@ -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<Settings extends GrIntroduceSetting
public static void assertStatement(@Nullable PsiElement anchor, @NotNull PsiElement scope) {
if (!(anchor instanceof GrStatement)) {
LogMessageEx.error(LOG, "cannot find anchor for variable", scope.getText());
LOG.error("cannot find anchor for variable", new Throwable(), AttachmentFactory.createContext(scope.getText()));
}
}
@@ -1,18 +1,4 @@
/*
* 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.designer.designSurface;
import com.intellij.designer.*;
@@ -30,7 +16,6 @@ import com.intellij.designer.propertyTable.InplaceContext;
import com.intellij.designer.propertyTable.PropertyTableTab;
import com.intellij.designer.propertyTable.TablePanelActionPolicy;
import com.intellij.diagnostic.AttachmentFactory;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.actionSystem.*;
import com.intellij.openapi.command.CommandProcessor;
@@ -56,7 +41,6 @@ import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.components.JBLabel;
import com.intellij.ui.components.JBLayeredPane;
import com.intellij.util.ArrayUtil;
import com.intellij.util.ExceptionUtil;
import com.intellij.util.ThrowableRunnable;
import com.intellij.util.containers.FixedHashMap;
import com.intellij.util.containers.IntArrayList;
@@ -365,9 +349,7 @@ public abstract class DesignerEditorPanel extends JPanel
showErrorPage(info);
}
if (info.myShowLog) {
LOG.error(LogMessageEx.createEvent(info.myDisplayMessage,
info.myMessage + "\n" + ExceptionUtil.getThrowableText(info.myThrowable),
getErrorAttachments(info)));
LOG.error(message, e, getErrorAttachments(info));
}
}
@@ -1,25 +1,9 @@
/*
* 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.util.xml.impl;
import com.intellij.diagnostic.LogMessageEx;
import com.intellij.openapi.diagnostic.Attachment;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.DebugUtil;
import com.intellij.psi.xml.XmlElement;
import com.intellij.psi.xml.XmlEntityRef;
import com.intellij.psi.xml.XmlFile;
@@ -126,19 +110,19 @@ public class PhysicalDomParentStrategy implements DomParentStrategy {
if (nav1 != nav2) {
PsiElement curContext = findIncluder(element);
PsiElement navContext = findIncluder(nav1);
LOG.error(LogMessageEx.createEvent(
"x:include processing error",
"nav1,nav2=" + nav1 + ", " + nav2 + ";\n" +
LOG.error(
"x:include processing error\n" +
"nav1,nav2=" + nav1 + "," + nav2 + ";\n" +
nav1.getContainingFile() + ":" + nav1.getTextRange().getStartOffset() + "!=" + nav2.getContainingFile() + ":" + nav2.getTextRange().getStartOffset() + ";\n" +
(nav1 == element) + ";" + (nav2 == thatElement) + ";\n" +
"contexts equal: " + (curContext == navContext) + ";\n" +
"curContext?.physical=" + (curContext != null && curContext.isPhysical()) + ";\n" +
"navContext?.physical=" + (navContext != null && navContext.isPhysical()) + ";\n" +
"myElement.physical=" + element.isPhysical() + ";\n" +
"thatElement.physical=" + thatElement.isPhysical() + "\n" + DebugUtil.currentStackTrace(),
"thatElement.physical=" + thatElement.isPhysical(),
new Throwable(),
new Attachment("Including tag text 1.xml", curContext == null ? "null" : curContext.getText()),
new Attachment("Including tag text 2.xml", navContext == null ? "null" : navContext.getText())
));
new Attachment("Including tag text 2.xml", navContext == null ? "null" : navContext.getText()));
throw new AssertionError();
}
}