Search in sources :

Example 1 with InstanceFilter

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

the class ToggleFieldBreakpointAction method actionPerformed.

@Override
public void actionPerformed(AnActionEvent e) {
    Project project = e.getData(CommonDataKeys.PROJECT);
    if (project == null) {
        return;
    }
    final SourcePosition place = getPlace(e);
    if (place != null) {
        Document document = PsiDocumentManager.getInstance(project).getDocument(place.getFile());
        if (document != null) {
            DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
            BreakpointManager manager = debuggerManager.getBreakpointManager();
            final int offset = place.getOffset();
            final Breakpoint breakpoint = offset >= 0 ? manager.findBreakpoint(document, offset, FieldBreakpoint.CATEGORY) : null;
            if (breakpoint == null) {
                FieldBreakpoint fieldBreakpoint = manager.addFieldBreakpoint(document, offset);
                if (fieldBreakpoint != null) {
                    if (DebuggerAction.isContextView(e)) {
                        final DebuggerTreeNodeImpl selectedNode = DebuggerAction.getSelectedNode(e.getDataContext());
                        if (selectedNode != null && selectedNode.getDescriptor() instanceof FieldDescriptorImpl) {
                            ObjectReference object = ((FieldDescriptorImpl) selectedNode.getDescriptor()).getObject();
                            if (object != null) {
                                long id = object.uniqueID();
                                InstanceFilter[] instanceFilters = new InstanceFilter[] { InstanceFilter.create(Long.toString(id)) };
                                fieldBreakpoint.setInstanceFilters(instanceFilters);
                                fieldBreakpoint.setInstanceFiltersEnabled(true);
                            }
                        }
                    }
                    final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
                    if (editor != null) {
                        manager.editBreakpoint(fieldBreakpoint, editor);
                    }
                }
            } else {
                manager.removeBreakpoint(breakpoint);
            }
        }
    }
}
Also used : FieldBreakpoint(com.intellij.debugger.ui.breakpoints.FieldBreakpoint) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) InstanceFilter(com.intellij.debugger.InstanceFilter) DebuggerManagerEx(com.intellij.debugger.DebuggerManagerEx) DebuggerTreeNodeImpl(com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl) FieldBreakpoint(com.intellij.debugger.ui.breakpoints.FieldBreakpoint) Document(com.intellij.openapi.editor.Document) BreakpointManager(com.intellij.debugger.ui.breakpoints.BreakpointManager) FieldBreakpoint(com.intellij.debugger.ui.breakpoints.FieldBreakpoint) Breakpoint(com.intellij.debugger.ui.breakpoints.Breakpoint) FieldDescriptorImpl(com.intellij.debugger.ui.impl.watch.FieldDescriptorImpl) Project(com.intellij.openapi.project.Project) ObjectReference(com.sun.jdi.ObjectReference) SourcePosition(com.intellij.debugger.SourcePosition) Editor(com.intellij.openapi.editor.Editor)

Example 2 with InstanceFilter

use of com.intellij.debugger.InstanceFilter in project kotlin by JetBrains.

the class KotlinBreakpointFiltersPanel method reloadInstanceFilters.

private void reloadInstanceFilters() {
    String filtersText = myInstanceFiltersField.getText();
    ArrayList<InstanceFilter> idxs = new ArrayList<InstanceFilter>();
    int startNumber = -1;
    for (int i = 0; i <= filtersText.length(); i++) {
        if (i < filtersText.length() && Character.isDigit(filtersText.charAt(i))) {
            if (startNumber == -1) {
                startNumber = i;
            }
        } else {
            if (startNumber >= 0) {
                idxs.add(InstanceFilter.create(filtersText.substring(startNumber, i)));
                startNumber = -1;
            }
        }
    }
    for (InstanceFilter instanceFilter : myInstanceFilters) {
        if (!instanceFilter.isEnabled()) {
            idxs.add(instanceFilter);
        }
    }
    myInstanceFilters = idxs.toArray(new InstanceFilter[idxs.size()]);
}
Also used : InstanceFilter(com.intellij.debugger.InstanceFilter) ArrayList(java.util.ArrayList) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint)

Example 3 with InstanceFilter

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

the class FilteredRequestorImpl method readExternal.

public void readExternal(Element parentNode) throws InvalidDataException {
    DefaultJDOMExternalizer.readExternal(this, parentNode);
    if (DebuggerSettings.SUSPEND_NONE.equals(SUSPEND_POLICY)) {
        // compatibility with older format
        SUSPEND = false;
        SUSPEND_POLICY = DebuggerSettings.SUSPEND_ALL;
    }
    String condition = JDOMExternalizerUtil.readField(parentNode, CONDITION_OPTION_NAME);
    if (condition != null) {
        setCondition(new TextWithImportsImpl(CodeFragmentKind.EXPRESSION, condition));
    }
    myClassFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(FILTER_OPTION_NAME));
    myClassExclusionFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(EXCLUSION_FILTER_OPTION_NAME));
    final ClassFilter[] instanceFilters = DebuggerUtilsEx.readFilters(parentNode.getChildren(INSTANCE_ID_OPTION_NAME));
    final List<InstanceFilter> iFilters = new ArrayList<>(instanceFilters.length);
    for (ClassFilter instanceFilter : instanceFilters) {
        try {
            iFilters.add(InstanceFilter.create(instanceFilter));
        } catch (Exception ignored) {
        }
    }
    myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]);
}
Also used : InstanceFilter(com.intellij.debugger.InstanceFilter) ClassFilter(com.intellij.ui.classFilter.ClassFilter) ArrayList(java.util.ArrayList) TextWithImportsImpl(com.intellij.debugger.engine.evaluation.TextWithImportsImpl)

Example 4 with InstanceFilter

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

the class JavaBreakpointFiltersPanel method updateInstanceFilterEditor.

private void updateInstanceFilterEditor(boolean updateText) {
    List<String> filters = new ArrayList<>();
    for (InstanceFilter instanceFilter : myInstanceFilters) {
        if (instanceFilter.isEnabled()) {
            filters.add(Long.toString(instanceFilter.getId()));
        }
    }
    if (updateText) {
        myInstanceFiltersField.setText(StringUtil.join(filters, " "));
    }
    String tipText = concatWithEx(filters, " ", (int) Math.sqrt(myInstanceFilters.length) + 1, "\n");
    myInstanceFiltersField.getTextField().setToolTipText(tipText);
}
Also used : InstanceFilter(com.intellij.debugger.InstanceFilter) ArrayList(java.util.ArrayList)

Example 5 with InstanceFilter

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

the class JavaBreakpointFiltersPanel method reloadInstanceFilters.

private void reloadInstanceFilters() {
    String filtersText = myInstanceFiltersField.getText();
    ArrayList<InstanceFilter> idxs = new ArrayList<>();
    int startNumber = -1;
    for (int i = 0; i <= filtersText.length(); i++) {
        if (i < filtersText.length() && Character.isDigit(filtersText.charAt(i))) {
            if (startNumber == -1) {
                startNumber = i;
            }
        } else {
            if (startNumber >= 0) {
                idxs.add(InstanceFilter.create(filtersText.substring(startNumber, i)));
                startNumber = -1;
            }
        }
    }
    myInstanceFilters = StreamEx.of(myInstanceFilters).remove(InstanceFilter::isEnabled).prepend(idxs).toArray(InstanceFilter[]::new);
}
Also used : InstanceFilter(com.intellij.debugger.InstanceFilter) ArrayList(java.util.ArrayList) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint)

Aggregations

InstanceFilter (com.intellij.debugger.InstanceFilter)6 ArrayList (java.util.ArrayList)5 XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)2 DebuggerManagerEx (com.intellij.debugger.DebuggerManagerEx)1 SourcePosition (com.intellij.debugger.SourcePosition)1 TextWithImportsImpl (com.intellij.debugger.engine.evaluation.TextWithImportsImpl)1 Breakpoint (com.intellij.debugger.ui.breakpoints.Breakpoint)1 BreakpointManager (com.intellij.debugger.ui.breakpoints.BreakpointManager)1 FieldBreakpoint (com.intellij.debugger.ui.breakpoints.FieldBreakpoint)1 DebuggerTreeNodeImpl (com.intellij.debugger.ui.impl.watch.DebuggerTreeNodeImpl)1 FieldDescriptorImpl (com.intellij.debugger.ui.impl.watch.FieldDescriptorImpl)1 Document (com.intellij.openapi.editor.Document)1 Editor (com.intellij.openapi.editor.Editor)1 Project (com.intellij.openapi.project.Project)1 ClassFilter (com.intellij.ui.classFilter.ClassFilter)1 ObjectReference (com.sun.jdi.ObjectReference)1