Skip to content

Commit dfc28df

Browse files
committed
Merge pull request #2273 from GKFX/patch-2
implement "import static"
2 parents c3d4d8d + 8317bec commit dfc28df

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
@@ -403,7 +403,7 @@ public String preprocess(File srcFolder,
403403
throw new SketchException(ex.toString());
404404
}
405405

406-
// grab the imports from the code just preproc'd
406+
// grab the imports from the code just preprocessed
407407

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

415415
// System.out.println("extra imports: " + result.extraImports);
416416
for (String item : result.extraImports) {
417+
// System.out.println("item = '" + item + "'");
417418
// remove things up to the last dot
418419
int dot = item.lastIndexOf('.');
419420
// http://dev.processing.org/bugs/show_bug.cgi?id=1145
420421
String entry = (dot == -1) ? item : item.substring(0, dot);
422+
// System.out.print(entry + " => ");
423+
424+
if (item.startsWith("static ")) {
425+
// import static - https://github.com/processing/processing/issues/8
426+
// Remove more stuff.
427+
int dot2 = item.lastIndexOf('.');
428+
entry = entry.substring(7, (dot2 == -1) ? entry.length() : dot2);
429+
// System.out.println(entry);
430+
}
431+
421432
// System.out.println("library searching for " + entry);
422433
Library library = mode.getLibrary(entry);
423434
// System.out.println(" found " + library);
@@ -433,15 +444,15 @@ public String preprocess(File srcFolder,
433444
// If someone insists on unnecessarily repeating the code folder
434445
// import, don't show an error for it.
435446
if (codeFolderPackages != null) {
436-
String itemPkg = item.substring(0, item.lastIndexOf('.'));
447+
String itemPkg = entry;
437448
for (String pkg : codeFolderPackages) {
438449
if (pkg.equals(itemPkg)) {
439450
found = true;
440451
break;
441452
}
442453
}
443454
}
444-
if (ignorableImport(item)) {
455+
if (ignorableImport(entry + '.')) {
445456
found = true;
446457
}
447458
if (!found) {

0 commit comments

Comments
 (0)