Search in sources :

Example 1 with Attachment

use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.

the class GroovyOptimizeImportsFix method invokeOnTheFlyImportOptimizer.

public static void invokeOnTheFlyImportOptimizer(@NotNull final Runnable runnable, @NotNull final PsiFile file, @NotNull final Editor editor) {
    final long stamp = editor.getDocument().getModificationStamp();
    Project project = file.getProject();
    TransactionGuard.submitTransaction(project, () -> {
        if (editor.isDisposed() || editor.getDocument().getModificationStamp() != stamp)
            return;
        //no need to optimize imports on the fly during undo/redo
        final UndoManager undoManager = UndoManager.getInstance(project);
        if (undoManager.isUndoInProgress() || undoManager.isRedoInProgress())
            return;
        PsiDocumentManager.getInstance(project).commitAllDocuments();
        String beforeText = file.getText();
        final long oldStamp = editor.getDocument().getModificationStamp();
        DocumentUtil.writeInRunUndoTransparentAction(runnable);
        if (oldStamp != editor.getDocument().getModificationStamp()) {
            String afterText = file.getText();
            if (Comparing.strEqual(beforeText, afterText)) {
                String path = file.getViewProvider().getVirtualFile().getPath();
                LOG.error("Import optimizer  hasn't optimized any imports", new Attachment(path, afterText));
            }
        }
    });
}
Also used : Project(com.intellij.openapi.project.Project) UndoManager(com.intellij.openapi.command.undo.UndoManager) Attachment(com.intellij.openapi.diagnostic.Attachment)

Example 2 with Attachment

use of com.intellij.openapi.diagnostic.Attachment in project smali by JesusFreke.

the class ITNProxy method createParameters.

public static Map<String, String> createParameters(ErrorBean error) {
    Map<String, String> params = ContainerUtil.newLinkedHashMap(40);
    params.put("protocol.version", "1");
    params.put("os.name", SystemProperties.getOsName());
    params.put("java.version", SystemProperties.getJavaVersion());
    params.put("java.vm.vendor", SystemProperties.getJavaVmVendor());
    ApplicationInfoEx appInfo = ApplicationInfoEx.getInstanceEx();
    ApplicationNamesInfo namesInfo = ApplicationNamesInfo.getInstance();
    Application application = ApplicationManager.getApplication();
    params.put("app.name", namesInfo.getProductName());
    params.put("app.name.full", namesInfo.getFullProductName());
    params.put("app.name.version", appInfo.getVersionName());
    params.put("app.eap", Boolean.toString(appInfo.isEAP()));
    params.put("app.internal", Boolean.toString(application.isInternal()));
    params.put("app.build", appInfo.getBuild().asString());
    params.put("app.version.major", appInfo.getMajorVersion());
    params.put("app.version.minor", appInfo.getMinorVersion());
    params.put("app.build.date", format(appInfo.getBuildDate()));
    params.put("app.build.date.release", format(appInfo.getMajorReleaseBuildDate()));
    params.put("app.compilation.timestamp", IdeaLogger.getOurCompilationTimestamp());
    UpdateSettings updateSettings = UpdateSettings.getInstance();
    params.put("update.channel.status", updateSettings.getSelectedChannelStatus().getCode());
    params.put("update.ignored.builds", StringUtil.join(updateSettings.getIgnoredBuildNumbers(), ","));
    params.put("plugin.name", error.getPluginName());
    params.put("plugin.version", error.getPluginVersion());
    params.put("last.action", error.getLastAction());
    params.put("previous.exception", error.getPreviousException() == null ? null : Integer.toString(error.getPreviousException()));
    params.put("error.message", error.getMessage());
    params.put("error.stacktrace", error.getStackTrace());
    params.put("error.description", error.getDescription());
    params.put("assignee.id", error.getAssigneeId() == null ? null : Integer.toString(error.getAssigneeId()));
    for (Attachment attachment : error.getAttachments()) {
        params.put("attachment.name", attachment.getName());
        params.put("attachment.value", attachment.getEncodedBytes());
    }
    return params;
}
Also used : ApplicationInfoEx(com.intellij.openapi.application.ex.ApplicationInfoEx) ApplicationNamesInfo(com.intellij.openapi.application.ApplicationNamesInfo) Attachment(com.intellij.openapi.diagnostic.Attachment) UpdateSettings(com.intellij.openapi.updateSettings.impl.UpdateSettings) Application(com.intellij.openapi.application.Application)

Example 3 with Attachment

use of com.intellij.openapi.diagnostic.Attachment in project intellij-elixir by KronicDeth.

the class Logger method error.

/**
     * Logs error {@link com.intellij.openapi.diagnostic.Logger} instance with the given {@code userMessage} and the
     * text of {@code element} as the details and containing file of {@code element} as an * attachment
     *
     * @param logger      logger to which to log an error.
     * @param userMessage User message for
     *                    {@link com.intellij.diagnostic.LogMessageEx#createEvent(String, String, Attachment...)}
     * @param element     element responsible for the error
     */
public static void error(@NotNull com.intellij.openapi.diagnostic.Logger logger, @NotNull String userMessage, @NotNull PsiElement element) {
    PsiFile containingFile = element.getContainingFile();
    String fullUserMessage = fullUserMessage(userMessage, containingFile, element);
    String details = Joiner.on("\n").join(new Throwable().getStackTrace());
    Collection<Attachment> attachmentCollection;
    VirtualFile virtualFile = containingFile.getVirtualFile();
    if (virtualFile != null) {
        attachmentCollection = Collections.singletonList(AttachmentFactory.createAttachment(virtualFile));
    } else {
        attachmentCollection = Collections.emptyList();
    }
    logger.error(LogMessageEx.createEvent(fullUserMessage, details, fullUserMessage, null, attachmentCollection));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) Attachment(com.intellij.openapi.diagnostic.Attachment)

Example 4 with Attachment

use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.

the class CachingSoftWrapDataMapper method advanceSoftWrapOffsets.

/**
   * Determines which soft wraps were not affected by recalculation, and shifts them to their new offsets.
   *
   * @return Change in soft wraps count after recalculation
   */
private void advanceSoftWrapOffsets(@NotNull IncrementalCacheUpdateEvent event) {
    int lengthDiff = event.getLengthDiff();
    int recalcEndOffsetTranslated = event.getActualEndOffset() - lengthDiff;
    int firstIndex = -1;
    int softWrappedLinesDiff = myStorage.getNumberOfSoftWrapsInRange(event.getStartOffset() + 1, myEditor.getDocument().getTextLength());
    boolean softWrapsChanged = softWrappedLinesDiff > 0;
    for (int i = 0; i < myAffectedByUpdateSoftWraps.size(); i++) {
        SoftWrap softWrap = myAffectedByUpdateSoftWraps.get(i);
        if (firstIndex < 0) {
            if (softWrap.getStart() > recalcEndOffsetTranslated) {
                firstIndex = i;
                if (lengthDiff == 0) {
                    break;
                }
            } else {
                softWrappedLinesDiff--;
                softWrapsChanged = true;
            }
        }
        if (firstIndex >= 0 && i >= firstIndex) {
            ((SoftWrapImpl) softWrap).advance(lengthDiff);
        }
    }
    if (firstIndex >= 0) {
        List<SoftWrapImpl> updated = myAffectedByUpdateSoftWraps.subList(firstIndex, myAffectedByUpdateSoftWraps.size());
        SoftWrapImpl lastSoftWrap = getLastSoftWrap();
        if (lastSoftWrap != null && lastSoftWrap.getStart() >= updated.get(0).getStart()) {
            LOG.error("Invalid soft wrap recalculation", new Attachment("state.txt", myEditor.getSoftWrapModel().toString()));
        }
        myStorage.addAll(updated);
    }
    myAffectedByUpdateSoftWraps.clear();
    if (softWrapsChanged) {
        myStorage.notifyListenersAboutChange();
    }
}
Also used : SoftWrapImpl(com.intellij.openapi.editor.impl.softwrap.SoftWrapImpl) Attachment(com.intellij.openapi.diagnostic.Attachment)

Example 5 with Attachment

use of com.intellij.openapi.diagnostic.Attachment in project intellij-community by JetBrains.

the class SingleRootFileViewProvider method checkLengthConsistency.

private void checkLengthConsistency() {
    Document document = getCachedDocument();
    if (document instanceof DocumentWindow) {
        return;
    }
    if (document != null && ((PsiDocumentManagerBase) PsiDocumentManager.getInstance(myManager.getProject())).getSynchronizer().isInSynchronization(document)) {
        return;
    }
    List<FileElement> knownTreeRoots = getKnownTreeRoots();
    if (knownTreeRoots.isEmpty())
        return;
    int fileLength = myContent.getTextLength();
    for (FileElement fileElement : knownTreeRoots) {
        int nodeLength = fileElement.getTextLength();
        if (nodeLength != fileLength) {
            PsiUtilCore.ensureValid(fileElement.getPsi());
            List<Attachment> attachments = ContainerUtil.newArrayList(new Attachment(myVirtualFile.getNameWithoutExtension() + ".tree.txt", fileElement.getText()), new Attachment(myVirtualFile.getNameWithoutExtension() + ".file.txt", myContent.toString()));
            if (document != null) {
                attachments.add(new Attachment(myVirtualFile.getNameWithoutExtension() + ".document.txt", document.getText()));
            }
            // exceptions here should be assigned to peter
            LOG.error("Inconsistent " + fileElement.getElementType() + " tree in " + this + "; nodeLength=" + nodeLength + "; fileLength=" + fileLength, attachments.toArray(Attachment.EMPTY_ARRAY));
        }
    }
}
Also used : DocumentWindow(com.intellij.injected.editor.DocumentWindow) FileElement(com.intellij.psi.impl.source.tree.FileElement) Attachment(com.intellij.openapi.diagnostic.Attachment) Document(com.intellij.openapi.editor.Document)

Aggregations

Attachment (com.intellij.openapi.diagnostic.Attachment)40 VirtualFile (com.intellij.openapi.vfs.VirtualFile)12 NotNull (org.jetbrains.annotations.NotNull)10 Project (com.intellij.openapi.project.Project)6 ArrayList (java.util.ArrayList)6 Document (com.intellij.openapi.editor.Document)5 TextRange (com.intellij.openapi.util.TextRange)4 LogEventException (com.intellij.diagnostic.LogEventException)3 PsiElement (com.intellij.psi.PsiElement)3 PsiFile (com.intellij.psi.PsiFile)3 LogMessageEx (com.intellij.diagnostic.LogMessageEx)2 JSQualifiedNamedElement (com.intellij.lang.javascript.psi.ecmal4.JSQualifiedNamedElement)2 Pair (com.intellij.openapi.util.Pair)2 PsiDocumentManager (com.intellij.psi.PsiDocumentManager)2 List (java.util.List)2 NonNls (org.jetbrains.annotations.NonNls)2 HighlightDisplayLevel (com.intellij.codeHighlighting.HighlightDisplayLevel)1 TextEditorHighlightingPass (com.intellij.codeHighlighting.TextEditorHighlightingPass)1 DaemonCodeAnalyzer (com.intellij.codeInsight.daemon.DaemonCodeAnalyzer)1 HighlightDisplayKey (com.intellij.codeInsight.daemon.HighlightDisplayKey)1