mirror of
https://github.com/processing/processing4.git
synced 2026-02-12 10:00:42 +01:00
finish cleaning up suggestions.txt handling and related code
This commit is contained in:
@@ -64,8 +64,10 @@ import com.google.classpath.RegExpResourceFilter;
|
||||
|
||||
@SuppressWarnings({ "unchecked" })
|
||||
public class CompletionGenerator {
|
||||
JavaMode mode;
|
||||
|
||||
public CompletionGenerator() {
|
||||
public CompletionGenerator(JavaMode mode) {
|
||||
this.mode = mode;
|
||||
//addCompletionPopupListner();
|
||||
//loadJavaDoc();
|
||||
}
|
||||
@@ -1285,7 +1287,7 @@ public class CompletionGenerator {
|
||||
}
|
||||
|
||||
|
||||
static protected boolean ignorableSuggestionImport(PreprocSketch ps, String impName) {
|
||||
protected boolean ignorableSuggestionImport(PreprocSketch ps, String impName) {
|
||||
String impNameLc = impName.toLowerCase();
|
||||
|
||||
List<ImportStatement> programImports = ps.programImports;
|
||||
@@ -1301,13 +1303,13 @@ public class CompletionGenerator {
|
||||
if (isImported) return false;
|
||||
|
||||
if (impName.startsWith("processing")) {
|
||||
if (JavaMode.includeSuggestion(impName)) {
|
||||
if (mode.includeSuggestion(impName)) {
|
||||
return false;
|
||||
} else if (JavaMode.excludeSuggestion(impName)) {
|
||||
} else if (mode.excludeSuggestion(impName)) {
|
||||
return true;
|
||||
}
|
||||
} else if (impName.startsWith("java")) {
|
||||
if (JavaMode.includeSuggestion(impName)) {
|
||||
if (mode.includeSuggestion(impName)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,6 @@ import processing.app.ui.Editor;
|
||||
import processing.app.ui.EditorException;
|
||||
import processing.app.ui.EditorState;
|
||||
|
||||
import processing.core.PApplet;
|
||||
import processing.mode.java.runner.Runner;
|
||||
import processing.mode.java.tweak.SketchParser;
|
||||
|
||||
@@ -49,7 +48,6 @@ public class JavaMode extends Mode {
|
||||
public JavaMode(Base base, File folder) {
|
||||
super(base, folder);
|
||||
|
||||
// initLogger();
|
||||
loadPreferences();
|
||||
loadSuggestionsMap();
|
||||
}
|
||||
@@ -238,16 +236,16 @@ 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.
|
||||
*/
|
||||
static private final Set<String> includedSuggestions = ConcurrentHashMap.newKeySet();
|
||||
static private final Set<String> excludedSuggestions = ConcurrentHashMap.newKeySet();
|
||||
private final Set<String> includedSuggestions = ConcurrentHashMap.newKeySet();
|
||||
private final Set<String> excludedSuggestions = ConcurrentHashMap.newKeySet();
|
||||
|
||||
|
||||
static boolean includeSuggestion(String impName) {
|
||||
boolean includeSuggestion(String impName) {
|
||||
return includedSuggestions.contains(impName);
|
||||
}
|
||||
|
||||
|
||||
static boolean excludeSuggestion(String impName) {
|
||||
boolean excludeSuggestion(String impName) {
|
||||
return excludedSuggestions.contains(impName);
|
||||
}
|
||||
|
||||
@@ -298,10 +296,15 @@ public class JavaMode extends Mode {
|
||||
}
|
||||
|
||||
|
||||
// While not pretty, loading from a file, and the necessary error-handling
|
||||
// is even uglier. And we're not modifying these externally anyway.
|
||||
private void loadSuggestionsMap() {
|
||||
Collections.addAll(includedSuggestions,
|
||||
Collections.addAll(includedSuggestions, getSuggestionIncludeList());
|
||||
Collections.addAll(excludedSuggestions, getSuggestionExcludeList());
|
||||
}
|
||||
|
||||
|
||||
// broken out so that it can be overridden by Android, etc
|
||||
protected String[] getSuggestionIncludeList() {
|
||||
return new String[] {
|
||||
"processing.core.PApplet",
|
||||
"processing.core.PFont",
|
||||
"processing.core.PGraphics",
|
||||
@@ -336,10 +339,14 @@ public class JavaMode extends Mode {
|
||||
"java.util.HashMap",
|
||||
"java.io.PrintWriter",
|
||||
"java.lang.String"
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Collections.addAll(excludedSuggestions,
|
||||
"processing.core.PGraphicsRetina2D",
|
||||
|
||||
// broken out so that it can be overridden by Android, etc
|
||||
protected String[] getSuggestionExcludeList() {
|
||||
return new String[] {
|
||||
"processing.core.PGraphicsRetina2D",
|
||||
"processing.core.PShapeOBJ",
|
||||
"processing.core.PShapeSVG",
|
||||
"processing.data.Sort",
|
||||
@@ -348,7 +355,7 @@ public class JavaMode extends Mode {
|
||||
"processing.opengl.LinePath.PathIterator",
|
||||
"processing.opengl.LineStroker",
|
||||
"processing.opengl.PGraphicsOpenGL"
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -52,8 +52,7 @@ public class JavaTextArea extends PdeTextArea {
|
||||
public JavaTextArea(TextAreaDefaults defaults, JavaEditor editor) {
|
||||
super(defaults, new JavaInputHandler(editor), editor);
|
||||
|
||||
suggestionGenerator = new CompletionGenerator();
|
||||
|
||||
suggestionGenerator = new CompletionGenerator((JavaMode) editor.getMode());
|
||||
tweakMode = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user