示例#1
0
 private String[] getImportStates(final Iterable<ClassFilter> filters) {
   List<String> importStates = new ArrayList<>();
   for (ClassFilter filter : filters) {
     importStates.add(String.valueOf(filter.isEnabled()));
   }
   return importStates.toArray(new String[importStates.size()]);
 }
示例#2
0
 private String[] getImportPatterns(final Iterable<ClassFilter> filters) {
   List<String> importsPatterns = new ArrayList<>();
   for (ClassFilter filter : filters) {
     importsPatterns.add(filter.getPattern());
   }
   return importsPatterns.toArray(new String[importsPatterns.size()]);
 }
示例#3
0
 private void retrieve() {
   if (propertiesComponent.isValueSet(RefreshActionBase.OLD_EXCLUDE_IMPORT_LIST)) {
     setOldImportsAsPatternAndState(
         propertiesComponent.getValue(RefreshActionBase.OLD_EXCLUDE_IMPORT_LIST));
     propertiesComponent.unsetValue(RefreshActionBase.OLD_EXCLUDE_IMPORT_LIST);
   }
   if (propertiesComponent.isValueSet(RefreshActionBase.EXCLUDE_IMPORT_PATTERN)
       && propertiesComponent.isValueSet(RefreshActionBase.EXCLUDE_IMPORT_STATE)) {
     String[] excludeImportStates =
         propertiesComponent.getValues(RefreshActionBase.EXCLUDE_IMPORT_STATE);
     String[] excludeImportPatterns =
         propertiesComponent.getValues(RefreshActionBase.EXCLUDE_IMPORT_PATTERN);
     if (excludeImportPatterns != null && excludeImportStates != null) {
       List<ClassFilter> filters =
           getClassFiltersFromPatternAndState(excludeImportPatterns, excludeImportStates);
       this.setFilterList(filters);
     }
   } else {
     List<ClassFilter> filters = new ArrayList<>();
     ClassFilter filter1 = new ClassFilter(DEFAULT_PATTERN_1);
     ClassFilter filter2 = new ClassFilter(DEFAULT_PATTERN_2);
     filter1.setEnabled(true);
     filter2.setEnabled(true);
     filters.add(filter1);
     filters.add(filter2);
     this.setFilterList(filters);
   }
   this.setExcludeImportsCheckBoxValue(
       Boolean.parseBoolean(
           propertiesComponent.getValue(
               RefreshActionBase.EXCLUDE_IMPORT_CHECKBOX_VALUE,
               RefreshActionBase.EXCLUDE_IMPORT_DEFAULT_CHECKBOX_VALUE)));
 }
 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);
     filter.writeExternal(element);
   }
 }
示例#5
0
 public static int getEnabledNumber(ClassFilter[] classFilters) {
   int res = 0;
   for (ClassFilter filter : classFilters) {
     if (filter.isEnabled()) {
       res++;
     }
   }
   return res;
 }
 public static ClassFilter[] readFilters(List children) throws InvalidDataException {
   if (children == null || children.size() == 0) {
     return ClassFilter.EMPTY_ARRAY;
   }
   List<ClassFilter> classFiltersList = new ArrayList<ClassFilter>(children.size());
   for (Iterator i = children.iterator(); i.hasNext(); ) {
     final ClassFilter classFilter = new ClassFilter();
     classFilter.readExternal((Element) i.next());
     classFiltersList.add(classFilter);
   }
   return classFiltersList.toArray(new ClassFilter[classFiltersList.size()]);
 }
示例#7
0
 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;
 }
示例#8
0
  public final List<ClassFilter> getClassFiltersFromPatternAndState(
      final String[] pExcludeImportPatterns, final String[] pExcludeImportStates) {

    List<ClassFilter> filtersList = new ArrayList<>();
    List<String> excludeImportPatterns = Arrays.asList(pExcludeImportPatterns);
    List<String> excludeImportStates = Arrays.asList(pExcludeImportStates);
    if (excludeImportPatterns.size() == excludeImportStates.size()
        && !containsOnlyEmptyString(excludeImportPatterns)
        && !containsOnlyEmptyString(excludeImportStates)) {
      for (int i = 0; i < excludeImportPatterns.size(); i++) {
        String pattern = excludeImportPatterns.get(i);
        boolean state = Boolean.valueOf(excludeImportStates.get(i));
        ClassFilter classFilter = new ClassFilter(pattern);
        classFilter.setEnabled(state);
        filtersList.add(classFilter);
      }
    }
    return filtersList;
  }
 public boolean evaluateCondition(EvaluationContextImpl context, LocatableEvent event)
     throws EvaluateException {
   if (CLASS_FILTERS_ENABLED) {
     String className = null;
     final ObjectReference thisObject = (ObjectReference) context.getThisObject();
     if (thisObject != null) {
       className = thisObject.referenceType().name();
     } else {
       final StackFrameProxyImpl frame = context.getFrameProxy();
       if (frame != null) {
         className = frame.location().declaringType().name();
       }
     }
     if (className != null) {
       boolean matches = false;
       for (ClassFilter classFilter : getClassFilters()) {
         if (classFilter.isEnabled() && classFilter.matches(className)) {
           matches = true;
           break;
         }
       }
       if (!matches) {
         return false;
       }
       for (ClassFilter classFilter : getClassExclusionFilters()) {
         if (classFilter.isEnabled() && classFilter.matches(className)) {
           return false;
         }
       }
     }
   }
   return super.evaluateCondition(context, event);
 }
 @SuppressWarnings("HardCodedStringLiteral")
 @NotNull
 public String getDescription() {
   final StringBuilder buf = StringBuilderSpinAllocator.alloc();
   try {
     buf.append("<html><body>");
     buf.append(getDisplayName());
     if (myInvalidMessage != null && !myInvalidMessage.isEmpty()) {
       buf.append("<br><font color='red'>");
       buf.append(DebuggerBundle.message("breakpoint.warning", myInvalidMessage));
       buf.append("</font>");
     }
     buf.append("&nbsp;<br>&nbsp;");
     buf.append(DebuggerBundle.message("breakpoint.property.name.suspend.policy")).append(" : ");
     if (DebuggerSettings.SUSPEND_NONE.equals(getSuspendPolicy()) || !isSuspend()) {
       buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.none"));
     } else if (DebuggerSettings.SUSPEND_ALL.equals(getSuspendPolicy())) {
       buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.all"));
     } else if (DebuggerSettings.SUSPEND_THREAD.equals(getSuspendPolicy())) {
       buf.append(DebuggerBundle.message("breakpoint.properties.panel.option.suspend.thread"));
     }
     buf.append("&nbsp;<br>&nbsp;");
     buf.append(DebuggerBundle.message("breakpoint.property.name.log.message")).append(": ");
     buf.append(isLogEnabled() ? CommonBundle.getYesButtonText() : CommonBundle.getNoButtonText());
     if (isLogExpressionEnabled()) {
       buf.append("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.log.expression")).append(": ");
       buf.append(XmlStringUtil.escapeString(getLogMessage().getText()));
     }
     if (isConditionEnabled()
         && getCondition() != null
         && getCondition().getText() != null
         && !getCondition().getText().isEmpty()) {
       buf.append("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.condition")).append(": ");
       buf.append(XmlStringUtil.escapeString(getCondition().getText()));
     }
     if (isCountFilterEnabled()) {
       buf.append("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.pass.count")).append(": ");
       buf.append(getCountFilter());
     }
     if (isClassFiltersEnabled()) {
       buf.append("&nbsp;<br>&nbsp;");
       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("&nbsp;<br>&nbsp;");
       buf.append(DebuggerBundle.message("breakpoint.property.name.instance.filters"));
       InstanceFilter[] instanceFilters = getInstanceFilters();
       for (InstanceFilter instanceFilter : instanceFilters) {
         buf.append(Long.toString(instanceFilter.getId())).append(" ");
       }
     }
     buf.append("</body></html>");
     return buf.toString();
   } finally {
     StringBuilderSpinAllocator.dispose(buf);
   }
 }
 public static ClassFilter create(Element element) throws InvalidDataException {
   ClassFilter filter = new ClassFilter();
   filter.readExternal(element);
   return filter;
 }