Skip to content

Commit 76a9fac

Browse files
committed
Modes can now specifiy additional jars for ecs/cc classpath
1 parent 145ce10 commit 76a9fac

File tree

3 files changed

+28
-8
lines changed

3 files changed

+28
-8
lines changed

java/src/processing/mode/java/JavaMode.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,14 @@ public boolean handleExportApplication(Sketch sketch) throws SketchException, IO
265265
}
266266

267267

268+
/**
269+
* Any modes that extend JavaMode can override this method to add additional jars to be
270+
* included in the classpath for code completion and error checking
271+
* @return searchPath: file-paths separated by File.pathSeparatorChar
272+
*/
268273
public String getSearchPath() {
269-
return System.getProperty("java.class.path") +
270-
File.pathSeparatorChar + System.getProperty("java.home") +
271-
File.separator + "lib" + File.separator + "rt.jar";
274+
// Java Mode doesn't need any default external jars at the moment.
275+
return "";
272276
}
273277

274278

java/src/processing/mode/java/pdex/ASTGenerator.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,14 +300,20 @@ protected void done() {
300300

301301
//protected JFrame frmJavaDoc;
302302

303+
protected String getJavaSearchPath() {
304+
return System.getProperty("java.class.path") +
305+
File.pathSeparatorChar + System.getProperty("java.home") +
306+
File.separator + "lib" + File.separator + "rt.jar";
307+
}
308+
303309
/**
304310
* Loads up .jar files and classes defined in it for completion lookup
305311
*/
306312
protected void loadJars() {
307313
factory = new ClassPathFactory();
308314

309315
StringBuilder path = new StringBuilder();
310-
String modeClassPath = ((JavaMode) editor.getMode()).getSearchPath();
316+
String modeClassPath = getJavaSearchPath() + File.pathSeparatorChar + ((JavaMode) editor.getMode()).getSearchPath();
311317
if (modeClassPath != null) {
312318
path.append(modeClassPath);
313319
}

java/src/processing/mode/java/pdex/ErrorCheckerService.java

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
package processing.mode.java.pdex;
2222

2323
import java.io.File;
24+
import java.net.MalformedURLException;
2425
import java.net.URL;
2526
import java.net.URLClassLoader;
2627
import java.util.ArrayList;
@@ -871,8 +872,17 @@ protected void prepareCompilerClasspath() {
871872
}
872873
}
873874
}
874-
}
875875

876+
// Also add jars specified in mode's search path
877+
String modeJars[] = ((JavaMode) getEditor().getMode()).getSearchPath().split(File.pathSeparatorChar + "");
878+
for (String mj : modeJars) {
879+
try {
880+
classpathJars.add(new File(mj).toURI().toURL());
881+
} catch (MalformedURLException e) {
882+
e.printStackTrace();
883+
}
884+
}
885+
}
876886
new Thread(new Runnable() {
877887
public void run() {
878888
astGenerator.loadJars(); // update jar file for completion lookup
@@ -1119,8 +1129,8 @@ protected String getPdeCodeAtLine(int tab, int linenumber){
11191129
* Calculates the tab number and line number of the error in that particular
11201130
* tab. Provides mapping between pure java and pde code.
11211131
*
1122-
* @param problem
1123-
* - IProblem
1132+
* @param javalineNumber
1133+
* - int
11241134
* @return int[0] - tab number, int[1] - line number
11251135
*/
11261136
protected int[] calculateTabIndexAndLineNumber(int javalineNumber) {
@@ -1335,7 +1345,7 @@ protected String preprocessCode(String pdeCode) {
13351345
/**
13361346
* Now defunct.
13371347
* The super method that highlights any ASTNode in the pde editor =D
1338-
* @param node
1348+
* @param awrap
13391349
* @return true - if highlighting happened correctly.
13401350
*/
13411351
private boolean highlightNode(ASTNodeWrapper awrap){

0 commit comments

Comments
 (0)