Skip to content

Commit

Permalink
Remove the ALL_CATEGORIES constant
Browse files Browse the repository at this point in the history
  • Loading branch information
gzsombor committed Jan 26, 2025
1 parent b8952fb commit eba40fd
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package org.eclipse.jdt.debug.core;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.core.resources.IMarker;
Expand All @@ -34,7 +33,6 @@
import org.eclipse.jdt.debug.core.IJavaStackFrame.Category;
import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
import org.eclipse.jdt.internal.debug.core.JavaDebugUtils;
import org.eclipse.jdt.internal.debug.core.StackFrameCategorizer;
import org.eclipse.jdt.internal.debug.core.breakpoints.JavaClassPrepareBreakpoint;
import org.eclipse.jdt.internal.debug.core.breakpoints.JavaExceptionBreakpoint;
import org.eclipse.jdt.internal.debug.core.breakpoints.JavaLineBreakpoint;
Expand Down Expand Up @@ -200,13 +198,6 @@ public class JDIDebugModel {
*/
public static final Category CATEGORY_UNKNOWN = new Category("UNKNOWN", true); //$NON-NLS-1$

/**
* All categories used by {@link StackFrameCategorizer}.
*
* @since 3.22
*/
public static final List<Category> ALL_CATEGORIES = List.of(CATEGORY_CUSTOM_FILTERED, CATEGORY_SYNTHETIC, CATEGORY_PLATFORM, CATEGORY_TEST, CATEGORY_PRODUCTION, CATEGORY_LIBRARY, CATEGORY_UNKNOWN);

/**
* Not to be instantiated.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@
package org.eclipse.jdt.internal.debug.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

Expand Down Expand Up @@ -60,18 +58,12 @@ boolean match(String fqcName) {

private Filters platform;
private Filters custom;
private final Map<Category, Boolean> enabledCategories;
private final IPreferencesService preferenceService;
private final IEclipsePreferences instancePreferences;

public StackFrameCategorizer(IPreferencesService preferenceService, IEclipsePreferences instancePreferences) {
this.preferenceService = preferenceService;
this.instancePreferences = instancePreferences;
enabledCategories = new HashMap<>();
for (var category : JDIDebugModel.ALL_CATEGORIES) {
boolean enabled = preferenceService.getBoolean(JDIDebugPlugin.getUniqueIdentifier(), getNameOfTheFlagToEnable(category), true, null);
enabledCategories.put(category, enabled);
}

platform = createActivePlatformFilters();
custom = createActiveCustomFilters();
Expand Down Expand Up @@ -180,23 +172,14 @@ private Category categorizeSourceElement(IJavaStackFrame frame) {
}

public boolean isEnabled(Category category) {
return Boolean.TRUE.equals(enabledCategories.get(category));
return preferenceService.getBoolean(JDIDebugPlugin.getUniqueIdentifier(), getNameOfTheFlagToEnable(category), true, null);
}

private String getNameOfTheFlagToEnable(Category category) {
return PREFIX + category.name();
}

private Category getCategoryFromNameOfTheFlag(String flagName) {
if (flagName.startsWith(PREFIX)) {
String categoryName = flagName.substring(PREFIX.length());
return JDIDebugModel.ALL_CATEGORIES.stream().filter(c -> categoryName.equals(c.name())).findAny().orElse(null);
}
return null;
}

public void setEnabled(Category category, boolean flag) {
enabledCategories.put(category, flag);
instancePreferences.putBoolean(getNameOfTheFlagToEnable(category), flag);
}

Expand Down Expand Up @@ -224,11 +207,6 @@ public void preferenceChange(PreferenceChangeEvent event) {
platform = createActivePlatformFilters();
} else if (JDIDebugPlugin.PREF_ACTIVE_CUSTOM_FRAME_FILTER_LIST.equals(prop)) {
custom = createActiveCustomFilters();
} else {
var category = getCategoryFromNameOfTheFlag(prop);
if (category != null) {
enabledCategories.put(category, (Boolean) event.getNewValue());
}
}
}

Expand Down

0 comments on commit eba40fd

Please sign in to comment.