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<InstanceFilter>(instanceFilters.length); for (ClassFilter instanceFilter : instanceFilters) { try { iFilters.add(InstanceFilter.create(instanceFilter)); } catch (Exception e) { } } myInstanceFilters = iFilters.isEmpty() ? InstanceFilter.EMPTY_ARRAY : iFilters.toArray(new InstanceFilter[iFilters.size()]); }
@Override public DebuggerSettings clone() { try { final DebuggerSettings cloned = (DebuggerSettings)super.clone(); cloned.myContentStates = new HashMap<String, ContentState>(); for (Map.Entry<String, ContentState> entry : myContentStates.entrySet()) { cloned.myContentStates.put(entry.getKey(), entry.getValue().clone()); } cloned.mySteppingFilters = new ClassFilter[mySteppingFilters.length]; for (int idx = 0; idx < mySteppingFilters.length; idx++) { cloned.mySteppingFilters[idx] = mySteppingFilters[idx].clone(); } return cloned; } catch (CloneNotSupportedException e) { LOG.error(e); } return null; }
@Override public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); // merge with prev results final String mergeAttribute = element.getAttributeValue(COVERAGE_MERGE_ATTRIBUTE_NAME); myIsMergeWithPreviousResults = mergeAttribute != null && Boolean.valueOf(mergeAttribute).booleanValue(); mySuiteToMergeWith = element.getAttributeValue(COVERAGE_MERGE_SUITE_ATT_NAME); // coverage patters List<Element> children = element.getChildren(COVERAGE_PATTERN_ELEMENT_NAME); if (children.size() > 0) { myCoveragePatterns = new ClassFilter[children.size()]; for (int i = 0; i < children.size(); i++) { Element e = children.get(i); myCoveragePatterns[i] = createClassFilter(e); String val = e.getAttributeValue("value"); if (val != null) { myCoveragePatterns[i].setPattern(val); } } } }
public void setUpCoverageFilters(@Nullable String className, @Nullable String packageName) { if (getCoveragePatterns() == null) { String pattern = null; if (!StringUtil.isEmpty(className)) { int index = className.lastIndexOf('.'); if (index >= 0) { pattern = className.substring(0, index); } } else if (packageName != null) { pattern = packageName; } if (!StringUtil.isEmpty(pattern)) { setCoveragePatterns(new ClassFilter[]{new ClassFilter(pattern + ".*")}); } } }
@SuppressWarnings({"HardCodedStringLiteral"}) public void readExternal(Element parentNode) throws InvalidDataException { DefaultJDOMExternalizer.readExternal(this, parentNode); List<ClassFilter> filtersList = new ArrayList<ClassFilter>(); for (final Object o : parentNode.getChildren("filter")) { Element filter = (Element)o; filtersList.add(DebuggerUtilsEx.create(filter)); } setSteppingFilters(filtersList.toArray(new ClassFilter[filtersList.size()])); filtersList.clear(); final List contents = parentNode.getChildren("content"); myContentStates.clear(); for (Object content : contents) { final ContentState state = new ContentState((Element)content); myContentStates.put(state.getType(), state); } }
@SuppressWarnings({"HardCodedStringLiteral"}) public void writeExternal(Element parentNode) throws WriteExternalException { DefaultJDOMExternalizer.writeExternal(this, parentNode); for (ClassFilter mySteppingFilter : mySteppingFilters) { Element element = new Element("filter"); parentNode.addContent(element); mySteppingFilter.writeExternal(element); } for (ContentState eachState : myContentStates.values()) { final Element content = new Element("content"); if (eachState.write(content)) { parentNode.addContent(content); } } }
public DebuggerSettings clone() { try { final DebuggerSettings cloned = (DebuggerSettings)super.clone(); cloned.myContentStates = new HashMap<String, ContentState>(); for (Map.Entry<String, ContentState> entry : myContentStates.entrySet()) { cloned.myContentStates.put(entry.getKey(), entry.getValue().clone()); } cloned.mySteppingFilters = new ClassFilter[mySteppingFilters.length]; for (int idx = 0; idx < mySteppingFilters.length; idx++) { cloned.mySteppingFilters[idx] = mySteppingFilters[idx].clone(); } return cloned; } catch (CloneNotSupportedException e) { LOG.error(e); } return null; }
public void readExternal(Element element) throws InvalidDataException { super.readExternal(element); // merge with prev results final String mergeAttribute = element.getAttributeValue(COVERAGE_MERGE_ATTRIBUTE_NAME); myIsMergeWithPreviousResults = mergeAttribute != null && Boolean.valueOf(mergeAttribute).booleanValue(); mySuiteToMergeWith = element.getAttributeValue(COVERAGE_MERGE_SUITE_ATT_NAME); // coverage patters final List children = element.getChildren(COVERAGE_PATTERN_ELEMENT_NAME); if (children.size() > 0) { myCoveragePatterns = new ClassFilter[children.size()]; for (int i = 0; i < children.size(); i++) { myCoveragePatterns[i] = new ClassFilter(); @NonNls final Element e = (Element)children.get(i); myCoveragePatterns[i].readExternal(e); final String val = e.getAttributeValue("value"); if (val != null) { myCoveragePatterns[i].setPattern(val); } } } }
public void setUpCoverageFilters(String className, String packageName) { if (getCoveragePatterns() == null) { String pattern = null; if (className != null && className.length() > 0) { int index = className.lastIndexOf('.'); if (index >= 0) { pattern = className.substring(0, index); } } else if (packageName != null) { pattern = packageName; } if (pattern != null && pattern.length() > 0) { setCoveragePatterns(new ClassFilter[]{new ClassFilter(pattern + ".*")}); } } }
protected com.intellij.ide.util.ClassFilter createClassConditionFilter() { com.intellij.ide.util.ClassFilter classFilter; if(myBreakpointPsiClass != null) { classFilter = new com.intellij.ide.util.ClassFilter() { @Override public boolean isAccepted(PsiClass aClass) { return myBreakpointPsiClass == aClass || aClass.isInheritor(myBreakpointPsiClass, true); } }; } else { classFilter = null; } return classFilter; }
protected static boolean typeMatchesClassFilters(@Nullable String typeName, ClassFilter[] includeFilters, ClassFilter[] exludeFilters) { if(typeName == null) { return true; } boolean matches = false, hasEnabled = false; for(ClassFilter classFilter : includeFilters) { if(classFilter.isEnabled()) { hasEnabled = true; if(classFilter.matches(typeName)) { matches = true; break; } } } if(hasEnabled && !matches) { return false; } return Arrays.stream(exludeFilters).noneMatch(classFilter -> classFilter.isEnabled() && classFilter.matches(typeName)); }
@Override public DebuggerSettings clone() { try { final DebuggerSettings cloned = (DebuggerSettings) super.clone(); cloned.myContentStates = new HashMap<>(); for(Map.Entry<String, ContentState> entry : myContentStates.entrySet()) { cloned.myContentStates.put(entry.getKey(), entry.getValue().clone()); } cloned.mySteppingFilters = new ClassFilter[mySteppingFilters.length]; for(int idx = 0; idx < mySteppingFilters.length; idx++) { cloned.mySteppingFilters[idx] = mySteppingFilters[idx].clone(); } cloned.myCapturePoints = cloneCapturePoints(); return cloned; } catch(CloneNotSupportedException e) { LOG.error(e); } return null; }
private static boolean isFiltered(ClassFilter classFilter, String qName) { if(!classFilter.isEnabled()) { return false; } try { if(classFilter.matches(qName)) { return true; } } catch(PatternSyntaxException e) { LOG.debug(e); } return false; }
public static ClassFilter[] createClassFilters(InstanceFilter[] filters) { ClassFilter [] cFilters = new ClassFilter[filters.length]; for (int i = 0; i < cFilters.length; i++) { InstanceFilter instanceFilter = filters[i]; ClassFilter classFilter = new ClassFilter(); classFilter.setEnabled(instanceFilter.isEnabled()); classFilter.setPattern(Long.toString(instanceFilter.getId())); cFilters[i] = classFilter; } return cFilters; }
public void actionPerformed(final AnActionEvent e) { final DebuggerContextImpl debuggerContext = DebuggerAction.getDebuggerContext(e.getDataContext()); DebugProcessImpl process = debuggerContext.getDebugProcess(); if (process == null) { return; } final StackFrameProxyImpl proxy = PopFrameAction.getStackFrameProxy(e); process.getManagerThread().schedule(new DebuggerCommandImpl() { protected void action() throws Exception { final String name = getClassName(proxy != null ? proxy : debuggerContext.getFrameProxy()); if (name == null) { return; } final Project project = e.getData(CommonDataKeys.PROJECT); ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { String filter = Messages.showInputDialog(project, "", "Add Stepping Filter", null, name, null); if (filter != null) { ClassFilter[] newFilters = ArrayUtil.append(DebuggerSettings.getInstance().getSteppingFilters(), new ClassFilter(filter)); DebuggerSettings.getInstance().setSteppingFilters(newFilters); } } }); } }); }
public ToStringRenderer clone() { final ToStringRenderer cloned = (ToStringRenderer)super.clone(); final ClassFilter[] classFilters = (myClassFilters.length > 0)? new ClassFilter[myClassFilters.length] : ClassFilter.EMPTY_ARRAY; for (int idx = 0; idx < classFilters.length; idx++) { classFilters[idx] = myClassFilters[idx].clone(); } cloned.myClassFilters = classFilters; return cloned; }
private boolean isFiltered(Type t) { if (t instanceof ReferenceType) { for (ClassFilter classFilter : myClassFilters) { if (classFilter.isEnabled() && DebuggerUtils.getSuperType(t, classFilter.getPattern()) != null) { return true; } } } return DebuggerUtilsEx.isFiltered(t.name(), myClassFilters); }
@SuppressWarnings("HardCodedStringLiteral") @NotNull public String getDescription() { final StringBuilder buf = StringBuilderSpinAllocator.alloc(); try { buf.append(getDisplayName()); if (isCountFilterEnabled()) { buf.append(" <br> "); buf.append(DebuggerBundle.message("breakpoint.property.name.pass.count")).append(": "); buf.append(getCountFilter()); } if (isClassFiltersEnabled()) { buf.append(" <br> "); buf.append(DebuggerBundle.message("breakpoint.property.name.class.filters")).append(": "); ClassFilter[] classFilters = getClassFilters(); for (ClassFilter classFilter : classFilters) { buf.append(classFilter.getPattern()).append(" "); } } if (isInstanceFiltersEnabled()) { buf.append(" <br> "); buf.append(DebuggerBundle.message("breakpoint.property.name.instance.filters")); InstanceFilter[] instanceFilters = getInstanceFilters(); for (InstanceFilter instanceFilter : instanceFilters) { buf.append(Long.toString(instanceFilter.getId())).append(" "); } } return buf.toString(); } finally { StringBuilderSpinAllocator.dispose(buf); } }
public InstanceFilter[] getFilters() { ClassFilter [] cFilters = myInstanceFilterEditor.getFilters(); InstanceFilter [] ifilters = new InstanceFilter[cFilters.length]; for (int i = 0; i < ifilters.length; i++) { ifilters[i] = InstanceFilter.create(cFilters[i]); } return ifilters; }
protected void addClassFilter() { String idString = Messages.showInputDialog(myProject, DebuggerBundle.message("add.instance.filter.dialog.prompt"), DebuggerBundle.message("add.instance.filter.dialog.title"), Messages.getQuestionIcon()); if (idString != null) { ClassFilter filter = createFilter(idString); if(filter != null){ myTableModel.addRow(filter); int row = myTableModel.getRowCount() - 1; myTable.getSelectionModel().setSelectionInterval(row, row); myTable.scrollRectToVisible(myTable.getCellRect(row, 0, true)); } myTable.requestFocus(); } }
protected ClassFilter createFilter(String pattern) { try { Long.parseLong(pattern); return super.createFilter(pattern); } catch (NumberFormatException e) { Messages.showMessageDialog(this, DebuggerBundle.message("add.instance.filter.dialog.error.numeric.value.expected"), DebuggerBundle.message("add.instance.filter.dialog.title"), Messages.getErrorIcon()); return null; } }
@Transient public ClassFilter[] getSteppingFilters() { final ClassFilter[] rv = new ClassFilter[mySteppingFilters.length]; for (int idx = 0; idx < rv.length; idx++) { rv[idx] = mySteppingFilters[idx].clone(); } return rv; }
private static boolean isFiltered(ClassFilter classFilter, String qName) { if (!classFilter.isEnabled()) { return false; } try { if (classFilter.matches(qName)) { return true; } } catch (PatternSyntaxException e) { LOG.debug(e); } return false; }
public static boolean isFiltered(@NotNull String qName, List<ClassFilter> classFilters) { if (qName.indexOf('[') != -1) { return false; //is array } for (ClassFilter filter : classFilters) { if (isFiltered(filter, qName)) { return true; } } return false; }
public static int getEnabledNumber(ClassFilter[] classFilters) { int res = 0; for (ClassFilter filter : classFilters) { if (filter.isEnabled()) { res++; } } return res; }
public static ClassFilter[] readFilters(List<Element> children) throws InvalidDataException { if (ContainerUtil.isEmpty(children)) { return ClassFilter.EMPTY_ARRAY; } ClassFilter[] filters = new ClassFilter[children.size()]; for (int i = 0, size = children.size(); i < size; i++) { filters[i] = create(children.get(i)); } return filters; }
public static void writeFilters(Element parentNode, @NonNls String tagName, ClassFilter[] filters) throws WriteExternalException { for (ClassFilter filter : filters) { Element element = new Element(tagName); parentNode.addContent(element); DefaultJDOMExternalizer.writeExternal(filter, element); } }
public static boolean filterEquals(ClassFilter[] filters1, ClassFilter[] filters2) { if (filters1.length != filters2.length) { return false; } final Set<ClassFilter> f1 = new HashSet<ClassFilter>(Math.max((int) (filters1.length/.75f) + 1, 16)); final Set<ClassFilter> f2 = new HashSet<ClassFilter>(Math.max((int) (filters2.length/.75f) + 1, 16)); Collections.addAll(f1, filters1); Collections.addAll(f2, filters2); return f2.equals(f1); }
@Override public List<ClassFilter> getFilters() { GroovyDebuggerSettings settings = GroovyDebuggerSettings.getInstance(); Boolean flag = settings.DEBUG_DISABLE_SPECIFIC_GROOVY_METHODS; if (flag == null || flag.booleanValue()) { return FILTERS; } return Collections.emptyList(); }
@Nullable public String [] getPatterns() { if (myCoveragePatterns != null) { List<String> patterns = new ArrayList<String>(); for (ClassFilter coveragePattern : myCoveragePatterns) { if (coveragePattern.isEnabled()) patterns.add(coveragePattern.getPattern()); } return ArrayUtil.toStringArray(patterns); } return null; }
@Nullable private static String[] getFilters(JavaCoverageEnabledConfiguration coverageEnabledConfiguration) { final ClassFilter[] patterns = coverageEnabledConfiguration.getCoveragePatterns(); if (patterns != null) { final List<String> filters = new ArrayList<String>(); for (ClassFilter classFilter : patterns) { filters.add(classFilter.getPattern()); } return ArrayUtil.toStringArray(filters); } return null; }
private boolean isFiltered(Type t) { if (t instanceof ReferenceType) { for (ClassFilter classFilter : myClassFilters) { if (classFilter.isEnabled() && DebuggerUtilsEx.getSuperType(t, classFilter.getPattern()) != null) { return true; } } } return DebuggerUtilsEx.isFiltered(t.name(), myClassFilters); }
public ClassFilter[] getSteppingFilters() { final ClassFilter[] rv = new ClassFilter[mySteppingFilters.length]; for (int idx = 0; idx < rv.length; idx++) { rv[idx] = mySteppingFilters[idx].clone(); } return rv; }