Search in sources :

Example 16 with ClassFilter

use of com.intellij.ui.classFilter.ClassFilter in project intellij-community by JetBrains.

the class InstanceFilterEditor method addClassFilter.

protected void addClassFilter() {
    String idString = Messages.showInputDialog(myProject, DebuggerBundle.message("add.instance.filter.dialog.prompt"), DebuggerBundle.message("add.instance.filter.dialog.title"), Messages.getQuestionIcon(), null, new InputValidatorEx() {

        @Nullable
        @Override
        public String getErrorText(String inputString) {
            try {
                //noinspection ResultOfMethodCallIgnored
                Long.parseLong(inputString);
                return null;
            } catch (NumberFormatException e) {
                return DebuggerBundle.message("add.instance.filter.dialog.error.numeric.value.expected");
            }
        }

        @Override
        public boolean checkInput(String inputString) {
            return getErrorText(inputString) == null;
        }

        @Override
        public boolean canClose(String inputString) {
            return getErrorText(inputString) == null;
        }
    });
    if (idString != null) {
        ClassFilter filter = createFilter(idString);
        myTableModel.addRow(filter);
        int row = myTableModel.getRowCount() - 1;
        myTable.getSelectionModel().setSelectionInterval(row, row);
        myTable.scrollRectToVisible(myTable.getCellRect(row, 0, true));
        IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> {
            IdeFocusManager.getGlobalInstance().requestFocus(myTable, true);
        });
    }
}
Also used : ClassFilter(com.intellij.ui.classFilter.ClassFilter) InputValidatorEx(com.intellij.openapi.ui.InputValidatorEx) Nullable(org.jetbrains.annotations.Nullable)

Example 17 with ClassFilter

use of com.intellij.ui.classFilter.ClassFilter in project intellij-community by JetBrains.

the class CoverageJavaRunConfigurationExtension method wrapElementListener.

@Override
public RefactoringElementListener wrapElementListener(PsiElement element, RunConfigurationBase configuration, RefactoringElementListener listener) {
    if (!isApplicableFor(configuration)) {
        return listener;
    }
    final JavaCoverageEnabledConfiguration coverageEnabledConfiguration = JavaCoverageEnabledConfiguration.getFrom(configuration);
    if (coverageEnabledConfiguration != null) {
        final Project project = configuration.getProject();
        final ClassFilter[] patterns = coverageEnabledConfiguration.getCoveragePatterns();
        final String[] filters = getFilters(coverageEnabledConfiguration);
        if (patterns != null) {
            assert filters != null;
            if (element instanceof PsiClass) {
                final String qualifiedName = ((PsiClass) element).getQualifiedName();
                final int idx = ArrayUtil.find(filters, qualifiedName);
                if (idx > -1) {
                    final RefactoringListeners.Accessor<PsiClass> accessor = new MyClassAccessor(project, patterns, idx, filters);
                    final RefactoringElementListener classListener = RefactoringListeners.getClassOrPackageListener(element, accessor);
                    if (classListener != null) {
                        listener = appendListener(listener, classListener);
                    }
                } else if (qualifiedName != null) {
                    final String packageName = StringUtil.getPackageName(qualifiedName);
                    if (!StringUtil.isEmpty(packageName)) {
                        for (int i = 0; i < filters.length; i++) {
                            String filter = filters[i];
                            if (filter.equals(packageName + ".*")) {
                                listener = appendListener(listener, new RefactoringListeners.RefactorPackageByClass(new MyClassAccessor(project, patterns, i, filters)));
                                break;
                            }
                        }
                    }
                }
            } else if (element instanceof PsiPackage) {
                final String qualifiedName = ((PsiPackage) element).getQualifiedName();
                for (int i = 0, filtersLength = filters.length; i < filtersLength; i++) {
                    if (filters[i].startsWith(qualifiedName + ".")) {
                        final RefactoringElementListener packageListener;
                        if (filters[i].endsWith("*")) {
                            packageListener = RefactoringListeners.getListener((PsiPackage) element, new MyPackageAccessor(project, patterns, i, filters));
                        } else {
                            packageListener = RefactoringListeners.getClassOrPackageListener(element, new MyClassAccessor(project, patterns, i, filters));
                        }
                        if (packageListener != null) {
                            listener = appendListener(listener, packageListener);
                        }
                    }
                }
            }
        }
    }
    return listener;
}
Also used : RefactoringElementListener(com.intellij.refactoring.listeners.RefactoringElementListener) PsiClass(com.intellij.psi.PsiClass) PsiPackage(com.intellij.psi.PsiPackage) JavaCoverageEnabledConfiguration(com.intellij.execution.configurations.coverage.JavaCoverageEnabledConfiguration) Project(com.intellij.openapi.project.Project) ClassFilter(com.intellij.ui.classFilter.ClassFilter) RefactoringListeners(com.intellij.execution.junit.RefactoringListeners)

Example 18 with ClassFilter

use of com.intellij.ui.classFilter.ClassFilter in project kotlin by JetBrains.

the class DebuggerSteppingHelper method createStepRequest.

// copied from DebugProcessImpl.doStep
private static void createStepRequest(@NotNull SuspendContextImpl suspendContext, @Nullable ThreadReferenceProxyImpl stepThread, @NotNull EventRequestManager requestManager, int size, int depth) {
    if (stepThread == null) {
        return;
    }
    try {
        ThreadReference stepThreadReference = stepThread.getThreadReference();
        requestManager.deleteEventRequests(requestManager.stepRequests());
        StepRequest stepRequest = requestManager.createStepRequest(stepThreadReference, size, depth);
        List<ClassFilter> activeFilters = getActiveFilters();
        if (!activeFilters.isEmpty()) {
            String currentClassName = getCurrentClassName(stepThread);
            if (currentClassName == null || !DebuggerUtilsEx.isFiltered(currentClassName, activeFilters)) {
                // add class filters
                for (ClassFilter filter : activeFilters) {
                    stepRequest.addClassExclusionFilter(filter.getPattern());
                }
            }
        }
        // suspend policy to match the suspend policy of the context:
        // if all threads were suspended, then during stepping all the threads must be suspended
        // if only event thread were suspended, then only this particular thread must be suspended during stepping
        stepRequest.setSuspendPolicy(suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_EVENT_THREAD ? EventRequest.SUSPEND_EVENT_THREAD : EventRequest.SUSPEND_ALL);
        stepRequest.enable();
    } catch (ObjectCollectedException ignored) {
    }
}
Also used : ObjectCollectedException(com.sun.jdi.ObjectCollectedException) ClassFilter(com.intellij.ui.classFilter.ClassFilter) StepRequest(com.sun.jdi.request.StepRequest) ThreadReference(com.sun.jdi.ThreadReference)

Aggregations

ClassFilter (com.intellij.ui.classFilter.ClassFilter)18 ArrayList (java.util.ArrayList)6 Project (com.intellij.openapi.project.Project)3 NotNull (org.jetbrains.annotations.NotNull)3 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)2 DebuggerSettings (com.intellij.debugger.settings.DebuggerSettings)2 PsiClass (com.intellij.psi.PsiClass)2 DebuggerClassFilterProvider (com.intellij.ui.classFilter.DebuggerClassFilterProvider)2 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)2 Element (org.jdom.Element)2 CoverageRunner (com.intellij.coverage.CoverageRunner)1 IDEACoverageRunner (com.intellij.coverage.IDEACoverageRunner)1 JavaCoverageRunner (com.intellij.coverage.JavaCoverageRunner)1 InstanceFilter (com.intellij.debugger.InstanceFilter)1 DebugProcessImpl (com.intellij.debugger.engine.DebugProcessImpl)1 TextWithImportsImpl (com.intellij.debugger.engine.evaluation.TextWithImportsImpl)1 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 DebuggerContextImpl (com.intellij.debugger.impl.DebuggerContextImpl)1 StackFrameProxyImpl (com.intellij.debugger.jdi.StackFrameProxyImpl)1 JavaCoverageEnabledConfiguration (com.intellij.execution.configurations.coverage.JavaCoverageEnabledConfiguration)1