cleaning up suggestions list access and remove unused lines

This commit is contained in:
Ben Fry
2021-08-01 13:15:47 -04:00
parent e74f36f1eb
commit 0fa9d19892
2 changed files with 14 additions and 15 deletions

View File

@@ -1289,8 +1289,7 @@ public class CompletionGenerator {
}
protected static boolean ignorableSuggestionImport(PreprocSketch ps, String impName) {
static protected boolean ignorableSuggestionImport(PreprocSketch ps, String impName) {
String impNameLc = impName.toLowerCase();
List<ImportStatement> programImports = ps.programImports;
@@ -1305,17 +1304,14 @@ public class CompletionGenerator {
if (isImported) return false;
final String include = "include";
final String exclude = "exclude";
if (impName.startsWith("processing")) {
if (JavaMode.suggestionsMap.containsKey(include) && JavaMode.suggestionsMap.get(include).contains(impName)) {
if (JavaMode.checkSuggestion("include", impName)) {
return false;
} else if (JavaMode.suggestionsMap.containsKey(exclude) && JavaMode.suggestionsMap.get(exclude).contains(impName)) {
} else if (JavaMode.checkSuggestion("exclude", impName)) {
return true;
}
} else if (impName.startsWith("java")) {
if (JavaMode.suggestionsMap.containsKey(include) && JavaMode.suggestionsMap.get(include).contains(impName)) {
if (JavaMode.checkSuggestion("include", impName)) {
return false;
}
}

View File

@@ -235,10 +235,17 @@ public class JavaMode extends Mode {
/**
* Stores the white list/black list of allowed/blacklisted imports. These are defined in
* suggestions.txt in java mode folder.
* Stores the white list/black list of allowed/blacklisted imports.
* These are defined in suggestions.txt in java mode folder.
*/
static public final Map<String, Set<String>> suggestionsMap = new HashMap<>();
static private final Map<String, Set<String>> suggestionsMap = new HashMap<>();
static boolean checkSuggestion(String mapName, String impName) {
return suggestionsMap.containsKey(mapName) &&
JavaMode.suggestionsMap.get(mapName).contains(impName);
}
public void loadPreferences() {
Messages.log("Load PDEX prefs");
@@ -246,10 +253,8 @@ public class JavaMode extends Mode {
errorCheckEnabled = Preferences.getBoolean(prefErrorCheck);
warningsEnabled = Preferences.getBoolean(prefWarnings);
codeCompletionsEnabled = Preferences.getBoolean(COMPLETION_PREF);
// DEBUG = Preferences.getBoolean(prefDebugOP);
errorLogsEnabled = Preferences.getBoolean(prefErrorLogs);
autoSaveInterval = Preferences.getInteger(prefAutoSaveInterval);
// untitledAutoSaveEnabled = Preferences.getBoolean(prefUntitledAutoSave);
autoSaveEnabled = Preferences.getBoolean(prefAutoSave);
autoSavePromptEnabled = Preferences.getBoolean(prefAutoSavePrompt);
defaultAutoSaveEnabled = Preferences.getBoolean(prefDefaultAutoSave);
@@ -265,10 +270,8 @@ public class JavaMode extends Mode {
Preferences.setBoolean(prefErrorCheck, errorCheckEnabled);
Preferences.setBoolean(prefWarnings, warningsEnabled);
Preferences.setBoolean(COMPLETION_PREF, codeCompletionsEnabled);
// Preferences.setBoolean(prefDebugOP, DEBUG);
Preferences.setBoolean(prefErrorLogs, errorLogsEnabled);
Preferences.setInteger(prefAutoSaveInterval, autoSaveInterval);
// Preferences.setBoolean(prefUntitledAutoSave,untitledAutoSaveEnabled);
Preferences.setBoolean(prefAutoSave, autoSaveEnabled);
Preferences.setBoolean(prefAutoSavePrompt, autoSavePromptEnabled);
Preferences.setBoolean(prefDefaultAutoSave, defaultAutoSaveEnabled);