Modes can now specifiy additional jars for ecs/cc classpath

This commit is contained in:
Manindra Moharana
2015-08-27 23:07:06 -07:00
parent b9f3d71272
commit 43ca4f1789
3 changed files with 28 additions and 8 deletions

View File

@@ -265,10 +265,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
* @return searchPath: file-paths separated by File.pathSeparatorChar
*/
public String getSearchPath() {
return System.getProperty("java.class.path") +
File.pathSeparatorChar + System.getProperty("java.home") +
File.separator + "lib" + File.separator + "rt.jar";
// Java Mode doesn't need any default external jars at the moment.
return "";
}

View File

@@ -300,6 +300,12 @@ public class ASTGenerator {
//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
*/
@@ -307,7 +313,7 @@ public class ASTGenerator {
factory = new ClassPathFactory();
StringBuilder path = new StringBuilder();
String modeClassPath = ((JavaMode) editor.getMode()).getSearchPath();
String modeClassPath = getJavaSearchPath() + File.pathSeparatorChar + ((JavaMode) editor.getMode()).getSearchPath();
if (modeClassPath != null) {
path.append(modeClassPath);
}

View File

@@ -21,6 +21,7 @@ along with this program; if not, write to the Free Software Foundation, Inc.
package processing.mode.java.pdex;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
@@ -871,8 +872,17 @@ public class ErrorCheckerService implements Runnable {
}
}
}
}
// 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();
}
}
}
new Thread(new Runnable() {
public void run() {
astGenerator.loadJars(); // update jar file for completion lookup
@@ -1119,8 +1129,8 @@ public class ErrorCheckerService implements Runnable {
* Calculates the tab number and line number of the error in that particular
* tab. Provides mapping between pure java and pde code.
*
* @param problem
* - IProblem
* @param javalineNumber
* - int
* @return int[0] - tab number, int[1] - line number
*/
protected int[] calculateTabIndexAndLineNumber(int javalineNumber) {
@@ -1335,7 +1345,7 @@ public class ErrorCheckerService implements Runnable {
/**
* Now defunct.
* The super method that highlights any ASTNode in the pde editor =D
* @param node
* @param awrap
* @return true - if highlighting happened correctly.
*/
private boolean highlightNode(ASTNodeWrapper awrap){