mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
scrubbing the class paths for #3812
This commit is contained in:
@@ -266,13 +266,14 @@ public class JavaMode extends Mode {
|
||||
|
||||
|
||||
/**
|
||||
* Any modes that extend JavaMode can override this method to add additional jars to be
|
||||
* included in the classpath for code completion and error checking
|
||||
* Any modes that extend JavaMode can override this method to add additional
|
||||
* JARs to be included in the classpath for code completion and error checking
|
||||
* @return searchPath: file-paths separated by File.pathSeparatorChar
|
||||
*/
|
||||
public String getSearchPath() {
|
||||
// Java Mode doesn't need any default external jars at the moment.
|
||||
return "";
|
||||
// This is here for Android Mode so that it can add its android.jar file.
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ import processing.app.SketchCode;
|
||||
import processing.app.Util;
|
||||
import processing.app.syntax.JEditTextArea;
|
||||
import processing.app.ui.Toolkit;
|
||||
import processing.data.StringList;
|
||||
import processing.mode.java.JavaEditor;
|
||||
import processing.mode.java.JavaMode;
|
||||
import processing.mode.java.preproc.PdePreprocessor;
|
||||
@@ -295,13 +296,6 @@ public class ASTGenerator {
|
||||
*/
|
||||
protected ClassPath classPath;
|
||||
|
||||
//protected JFrame frmJavaDoc;
|
||||
|
||||
protected String getJavaSearchPath() {
|
||||
return System.getProperty("java.class.path") +
|
||||
File.pathSeparatorChar + System.getProperty("java.home") +
|
||||
File.separator + "lib" + File.separator + "rt.jar";
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads up .jar files and classes defined in it for completion lookup
|
||||
@@ -309,22 +303,36 @@ public class ASTGenerator {
|
||||
protected void loadJars() {
|
||||
factory = new ClassPathFactory();
|
||||
|
||||
StringBuilder path = new StringBuilder();
|
||||
String modeClassPath = getJavaSearchPath() + File.pathSeparatorChar + ((JavaMode) editor.getMode()).getSearchPath();
|
||||
StringList entries = new StringList();
|
||||
entries.append(System.getProperty("java.class.path"));
|
||||
entries.append(System.getProperty("java.home") +
|
||||
File.separator + "lib" + File.separator + "rt.jar");
|
||||
|
||||
String modeClassPath = ((JavaMode) editor.getMode()).getSearchPath();
|
||||
if (modeClassPath != null) {
|
||||
path.append(modeClassPath);
|
||||
entries.append(modeClassPath);
|
||||
}
|
||||
|
||||
if (errorCheckerService.classpathJars != null) {
|
||||
synchronized (errorCheckerService.classpathJars) {
|
||||
for (URL jarPath : errorCheckerService.classpathJars) {
|
||||
//log(jarPath.getPath());
|
||||
path.append(jarPath.getPath() + File.pathSeparatorChar);
|
||||
entries.append(jarPath.getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
classPath = factory.createFromPath(path.toString());
|
||||
// // Just in case, make sure we don't run off into oblivion
|
||||
// String workingDirectory = System.getProperty("user.dir");
|
||||
// if (entries.removeValue(workingDirectory) != -1) {
|
||||
// System.err.println("user.dir found in classpath");
|
||||
// }
|
||||
|
||||
// // hm, these weren't problematic either
|
||||
// entries.append(System.getProperty("user.dir"));
|
||||
// entries.append("");
|
||||
// entries.print();
|
||||
|
||||
classPath = factory.createFromPath(entries.join(File.pathSeparator));
|
||||
log("Classpath created " + (classPath != null));
|
||||
log("Sketch classpath jars loaded.");
|
||||
if (Platform.isMacOS()) {
|
||||
|
||||
@@ -887,17 +887,18 @@ public class ErrorCheckerService implements Runnable {
|
||||
e2.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Also add jars specified in mode's search path
|
||||
String modeJars[] = ((JavaMode) getEditor().getMode()).getSearchPath().split(File.pathSeparatorChar + "");
|
||||
for (String mj : modeJars) {
|
||||
try {
|
||||
classpathJars.add(new File(mj).toURI().toURL());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
String searchPath = ((JavaMode) getEditor().getMode()).getSearchPath();
|
||||
if (searchPath != null) {
|
||||
String[] modeJars = PApplet.split(searchPath, File.pathSeparatorChar);
|
||||
for (String mj : modeJars) {
|
||||
try {
|
||||
classpathJars.add(new File(mj).toURI().toURL());
|
||||
} catch (MalformedURLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user