Skip to content

Commit 8317bec

Browse files
committed
Update JavaBuild.java
Fix bug #8.
1 parent 0b7471d commit 8317bec

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

app/src/processing/mode/java/JavaBuild.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ public String preprocess(File srcFolder,
397397
throw new SketchException(ex.toString());
398398
}
399399

400-
// grab the imports from the code just preproc'd
400+
// grab the imports from the code just preprocessed
401401

402402
importedLibraries = new ArrayList<Library>();
403403
Library core = mode.getCoreLibrary();
@@ -408,10 +408,21 @@ public String preprocess(File srcFolder,
408408

409409
// System.out.println("extra imports: " + result.extraImports);
410410
for (String item : result.extraImports) {
411+
// System.out.println("item = '" + item + "'");
411412
// remove things up to the last dot
412413
int dot = item.lastIndexOf('.');
413414
// http://dev.processing.org/bugs/show_bug.cgi?id=1145
414415
String entry = (dot == -1) ? item : item.substring(0, dot);
416+
// System.out.print(entry + " => ");
417+
418+
if (item.startsWith("static ")) {
419+
// import static - https://github.com/processing/processing/issues/8
420+
// Remove more stuff.
421+
int dot2 = item.lastIndexOf('.');
422+
entry = entry.substring(7, (dot2 == -1) ? entry.length() : dot2);
423+
// System.out.println(entry);
424+
}
425+
415426
// System.out.println("library searching for " + entry);
416427
Library library = mode.getLibrary(entry);
417428
// System.out.println(" found " + library);
@@ -427,15 +438,15 @@ public String preprocess(File srcFolder,
427438
// If someone insists on unnecessarily repeating the code folder
428439
// import, don't show an error for it.
429440
if (codeFolderPackages != null) {
430-
String itemPkg = item.substring(0, item.lastIndexOf('.'));
441+
String itemPkg = entry;
431442
for (String pkg : codeFolderPackages) {
432443
if (pkg.equals(itemPkg)) {
433444
found = true;
434445
break;
435446
}
436447
}
437448
}
438-
if (ignorableImport(item)) {
449+
if (ignorableImport(entry + '.')) {
439450
found = true;
440451
}
441452
if (!found) {

0 commit comments

Comments
 (0)