Search in sources :

Example 1 with DebuggerSettings

use of com.intellij.debugger.settings.DebuggerSettings in project kotlin by JetBrains.

the class DebuggerSteppingHelper method getActiveFilters.

// copied from DebugProcessImpl.getActiveFilters
@NotNull
private static List<ClassFilter> getActiveFilters() {
    List<ClassFilter> activeFilters = new ArrayList<ClassFilter>();
    DebuggerSettings settings = DebuggerSettings.getInstance();
    if (settings.TRACING_FILTERS_ENABLED) {
        for (ClassFilter filter : settings.getSteppingFilters()) {
            if (filter.isEnabled()) {
                activeFilters.add(filter);
            }
        }
    }
    for (DebuggerClassFilterProvider provider : Extensions.getExtensions(DebuggerClassFilterProvider.EP_NAME)) {
        for (ClassFilter filter : provider.getFilters()) {
            if (filter.isEnabled()) {
                activeFilters.add(filter);
            }
        }
    }
    return activeFilters;
}
Also used : DebuggerSettings(com.intellij.debugger.settings.DebuggerSettings) DebuggerClassFilterProvider(com.intellij.ui.classFilter.DebuggerClassFilterProvider) ClassFilter(com.intellij.ui.classFilter.ClassFilter) ArrayList(java.util.ArrayList) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with DebuggerSettings

use of com.intellij.debugger.settings.DebuggerSettings in project intellij-community by JetBrains.

the class RequestHint method getNextStepDepth.

public int getNextStepDepth(final SuspendContextImpl context) {
    try {
        final StackFrameProxyImpl frameProxy = context.getFrameProxy();
        // smart step feature stop check
        if (myMethodFilter != null && frameProxy != null && !(myMethodFilter instanceof BreakpointStepMethodFilter) && myMethodFilter.locationMatches(context.getDebugProcess(), frameProxy.location()) && !isTheSameFrame(context)) {
            myTargetMethodMatched = true;
            return myMethodFilter.onReached(context, this);
        }
        if ((myDepth == StepRequest.STEP_OVER || myDepth == StepRequest.STEP_INTO) && myPosition != null) {
            SourcePosition locationPosition = ContextUtil.getSourcePosition(context);
            if (locationPosition != null) {
                Integer resultDepth = ApplicationManager.getApplication().runReadAction(new Computable<Integer>() {

                    public Integer compute() {
                        if (myPosition.getFile().equals(locationPosition.getFile()) && isTheSameFrame(context) && !mySteppedOut) {
                            return isOnTheSameLine(locationPosition) ? myDepth : STOP;
                        }
                        return null;
                    }
                });
                if (resultDepth != null) {
                    return resultDepth.intValue();
                }
            }
        }
        // Now check filters
        final DebuggerSettings settings = DebuggerSettings.getInstance();
        if ((myMethodFilter != null || (settings.SKIP_SYNTHETIC_METHODS && !myIgnoreFilters)) && frameProxy != null) {
            final Location location = frameProxy.location();
            if (location != null) {
                if (DebuggerUtils.isSynthetic(location.method())) {
                    return myDepth;
                }
            }
        }
        if (!myIgnoreFilters) {
            if (settings.SKIP_GETTERS) {
                boolean isGetter = ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {

                    public Boolean compute() {
                        PsiElement contextElement = ContextUtil.getContextElement(context);
                        return contextElement != null && DebuggerUtils.isInsideSimpleGetter(contextElement);
                    }
                }).booleanValue();
                if (isGetter) {
                    return StepRequest.STEP_OUT;
                }
            }
            if (frameProxy != null) {
                if (settings.SKIP_CONSTRUCTORS) {
                    final Location location = frameProxy.location();
                    if (location != null) {
                        final Method method = location.method();
                        if (method != null && method.isConstructor()) {
                            return StepRequest.STEP_OUT;
                        }
                    }
                }
                if (settings.SKIP_CLASSLOADERS) {
                    final Location location = frameProxy.location();
                    if (location != null && DebuggerUtilsEx.isAssignableFrom("java.lang.ClassLoader", location.declaringType())) {
                        return StepRequest.STEP_OUT;
                    }
                }
            }
            for (ExtraSteppingFilter filter : ExtraSteppingFilter.EP_NAME.getExtensions()) {
                try {
                    if (filter.isApplicable(context))
                        return filter.getStepRequestDepth(context);
                } catch (Exception | AssertionError e) {
                    LOG.error(e);
                }
            }
        }
        // smart step feature
        if (myMethodFilter != null && !mySteppedOut) {
            return StepRequest.STEP_OUT;
        }
    } catch (VMDisconnectedException ignored) {
    } catch (EvaluateException e) {
        LOG.error(e);
    }
    return STOP;
}
Also used : StackFrameProxyImpl(com.intellij.debugger.jdi.StackFrameProxyImpl) DebuggerSettings(com.intellij.debugger.settings.DebuggerSettings) Method(com.sun.jdi.Method) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) VMDisconnectedException(com.sun.jdi.VMDisconnectedException) VMDisconnectedException(com.sun.jdi.VMDisconnectedException) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) SourcePosition(com.intellij.debugger.SourcePosition) Computable(com.intellij.openapi.util.Computable) PsiElement(com.intellij.psi.PsiElement) Location(com.sun.jdi.Location)

Example 3 with DebuggerSettings

use of com.intellij.debugger.settings.DebuggerSettings in project intellij-community by JetBrains.

the class DebugProcessImpl method getActiveFilters.

@NotNull
private static List<ClassFilter> getActiveFilters() {
    DebuggerSettings settings = DebuggerSettings.getInstance();
    StreamEx<ClassFilter> stream = StreamEx.of(Extensions.getExtensions(DebuggerClassFilterProvider.EP_NAME)).flatCollection(DebuggerClassFilterProvider::getFilters);
    if (settings.TRACING_FILTERS_ENABLED) {
        stream = stream.prepend(settings.getSteppingFilters());
    }
    return stream.filter(ClassFilter::isEnabled).toList();
}
Also used : DebuggerSettings(com.intellij.debugger.settings.DebuggerSettings) DebuggerClassFilterProvider(com.intellij.ui.classFilter.DebuggerClassFilterProvider) ClassFilter(com.intellij.ui.classFilter.ClassFilter) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with DebuggerSettings

use of com.intellij.debugger.settings.DebuggerSettings in project intellij-community by JetBrains.

the class HotSwapUIImpl method hotSwapSessions.

private void hotSwapSessions(final List<DebuggerSession> sessions, @Nullable final Map<String, List<String>> generatedPaths) {
    final boolean shouldAskBeforeHotswap = myAskBeforeHotswap;
    myAskBeforeHotswap = true;
    final DebuggerSettings settings = DebuggerSettings.getInstance();
    final String runHotswap = settings.RUN_HOTSWAP_AFTER_COMPILE;
    final boolean shouldDisplayHangWarning = shouldDisplayHangWarning(settings, sessions);
    if (shouldAskBeforeHotswap && DebuggerSettings.RUN_HOTSWAP_NEVER.equals(runHotswap)) {
        return;
    }
    final boolean shouldPerformScan = generatedPaths == null;
    final HotSwapProgressImpl findClassesProgress;
    if (shouldPerformScan) {
        findClassesProgress = new HotSwapProgressImpl(myProject);
    } else {
        boolean createProgress = false;
        for (DebuggerSession session : sessions) {
            if (session.isModifiedClassesScanRequired()) {
                createProgress = true;
                break;
            }
        }
        findClassesProgress = createProgress ? new HotSwapProgressImpl(myProject) : null;
    }
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final Map<DebuggerSession, Map<String, HotSwapFile>> modifiedClasses;
        if (shouldPerformScan) {
            modifiedClasses = scanForModifiedClassesWithProgress(sessions, findClassesProgress);
        } else {
            final List<DebuggerSession> toScan = new ArrayList<>();
            final List<DebuggerSession> toUseGenerated = new ArrayList<>();
            for (DebuggerSession session : sessions) {
                (session.isModifiedClassesScanRequired() ? toScan : toUseGenerated).add(session);
                session.setModifiedClassesScanRequired(false);
            }
            modifiedClasses = new HashMap<>();
            if (!toUseGenerated.isEmpty()) {
                modifiedClasses.putAll(HotSwapManager.findModifiedClasses(toUseGenerated, generatedPaths));
            }
            if (!toScan.isEmpty()) {
                modifiedClasses.putAll(scanForModifiedClassesWithProgress(toScan, findClassesProgress));
            }
        }
        final Application application = ApplicationManager.getApplication();
        if (modifiedClasses.isEmpty()) {
            final String message = DebuggerBundle.message("status.hotswap.uptodate");
            HotSwapProgressImpl.NOTIFICATION_GROUP.createNotification(message, NotificationType.INFORMATION).notify(myProject);
            return;
        }
        application.invokeLater(() -> {
            if (shouldAskBeforeHotswap && !DebuggerSettings.RUN_HOTSWAP_ALWAYS.equals(runHotswap)) {
                final RunHotswapDialog dialog = new RunHotswapDialog(myProject, sessions, shouldDisplayHangWarning);
                if (!dialog.showAndGet()) {
                    for (DebuggerSession session : modifiedClasses.keySet()) {
                        session.setModifiedClassesScanRequired(true);
                    }
                    return;
                }
                final Set<DebuggerSession> toReload = new HashSet<>(dialog.getSessionsToReload());
                for (DebuggerSession session : modifiedClasses.keySet()) {
                    if (!toReload.contains(session)) {
                        session.setModifiedClassesScanRequired(true);
                    }
                }
                modifiedClasses.keySet().retainAll(toReload);
            } else {
                if (shouldDisplayHangWarning) {
                    final int answer = Messages.showCheckboxMessageDialog(DebuggerBundle.message("hotswap.dialog.hang.warning"), DebuggerBundle.message("hotswap.dialog.title"), new String[] { "Perform &Reload Classes", "&Skip Reload Classes" }, CommonBundle.message("dialog.options.do.not.show"), false, 1, 1, Messages.getWarningIcon(), (exitCode, cb) -> {
                        settings.HOTSWAP_HANG_WARNING_ENABLED = !cb.isSelected();
                        return exitCode == DialogWrapper.OK_EXIT_CODE ? exitCode : DialogWrapper.CANCEL_EXIT_CODE;
                    });
                    if (answer == DialogWrapper.CANCEL_EXIT_CODE) {
                        for (DebuggerSession session : modifiedClasses.keySet()) {
                            session.setModifiedClassesScanRequired(true);
                        }
                        return;
                    }
                }
            }
            if (!modifiedClasses.isEmpty()) {
                final HotSwapProgressImpl progress = new HotSwapProgressImpl(myProject);
                if (modifiedClasses.keySet().size() == 1) {
                    //noinspection ConstantConditions
                    progress.setSessionForActions(ContainerUtil.getFirstItem(modifiedClasses.keySet()));
                }
                application.executeOnPooledThread(() -> reloadModifiedClasses(modifiedClasses, progress));
            }
        }, ModalityState.NON_MODAL);
    });
}
Also used : DebuggerSettings(com.intellij.debugger.settings.DebuggerSettings) DebuggerSession(com.intellij.debugger.impl.DebuggerSession) Application(com.intellij.openapi.application.Application) THashSet(gnu.trove.THashSet)

Aggregations

DebuggerSettings (com.intellij.debugger.settings.DebuggerSettings)4 ClassFilter (com.intellij.ui.classFilter.ClassFilter)2 DebuggerClassFilterProvider (com.intellij.ui.classFilter.DebuggerClassFilterProvider)2 NotNull (org.jetbrains.annotations.NotNull)2 SourcePosition (com.intellij.debugger.SourcePosition)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 DebuggerSession (com.intellij.debugger.impl.DebuggerSession)1 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)1 Application (com.intellij.openapi.application.Application)1 Computable (com.intellij.openapi.util.Computable)1 PsiElement (com.intellij.psi.PsiElement)1 Location (com.sun.jdi.Location)1 Method (com.sun.jdi.Method)1 VMDisconnectedException (com.sun.jdi.VMDisconnectedException)1 THashSet (gnu.trove.THashSet)1 ArrayList (java.util.ArrayList)1