deal with erroneous warning messages about missing libs with code folder, also if android.* classes are used (issue #568)

This commit is contained in:
benfry
2011-04-10 20:14:39 +00:00
parent 275b310dee
commit 93bed5cdd1
6 changed files with 109 additions and 67 deletions

View File

@@ -216,15 +216,18 @@ public class Compiler {
errorMessage.endsWith("cannot be resolved")) {
// The import poo cannot be resolved
//import poo.shoe.blah.*;
String what = errorMessage.substring("The import ".length());
what = what.substring(0, what.indexOf(' '));
System.err.println("Note that release 1.0, libraries must be " +
//String what = errorMessage.substring("The import ".length());
String[] m = PApplet.match(errorMessage, "The import (.*) cannot be resolved");
//what = what.substring(0, what.indexOf(' '));
if (m != null) {
exception.setMessage("The package " +
"\u201C" + m[1] + "\u201D" +
" does not exist. " +
"You might be missing a library.");
}
System.err.println("As of release 1.0, libraries must be " +
"installed in a folder named 'libraries' " +
"inside the 'sketchbook' folder.");
exception.setMessage("The package " +
"\u201C" + what + "\u201D" +
" does not exist. " +
"You might be missing a library.");
// // Actually create the folder and open it for the user
// File sketchbookLibraries = Base.getSketchbookLibrariesFolder();

View File

@@ -73,14 +73,8 @@ public class JavaBuild {
* List of library folders, as figured out during preprocessing.
*/
private ArrayList<Library> importedLibraries;
//private ArrayList<File> importedLibraries;
// public Build(Editor editor) {
// this.editor = editor;
// this.sketch = editor.getSketch();
// }
public JavaBuild(Sketch sketch) {
this.sketch = sketch;
this.mode = sketch.getMode();
@@ -397,12 +391,22 @@ public class JavaBuild {
javaLibraryPath += File.pathSeparator + library.getNativePath();
}
} else {
// Don't bother complaining about java.* or javax.* because it's
// probably in boot.class.path. But we're not checking against that
// path since it's enormous. Unfortunately we do still have to check
// for libraries that begin with a prefix like javax, since that
// includes the OpenGL library.
if (!item.startsWith("java.") && !item.startsWith("javax.")) {
boolean found = false;
// If someone insists on unnecessarily repeating the code folder
// import, don't show an error for it.
if (codeFolderPackages != null) {
String itemPkg = item.substring(0, item.lastIndexOf('.'));
for (String pkg : codeFolderPackages) {
if (pkg.equals(itemPkg)) {
found = true;
break;
}
}
}
if (ignorableImport(item)) {
found = true;
}
if (!found) {
System.err.println("No library found for " + entry);
}
}
@@ -472,6 +476,20 @@ public class JavaBuild {
foundMain = preprocessor.getFoundMain();
return result.className;
}
/**
* Returns true if this package isn't part of a library (it's a system import
* or something like that). Don't bother complaining about java.* or javax.*
* because it's probably in boot.class.path. But we're not checking against
* that path since it's enormous. Unfortunately we do still have to check
* for libraries that begin with a prefix like javax, since that includes
* the OpenGL library, even though we're just returning true here, hrm...
*/
protected boolean ignorableImport(String pkg) {
if (pkg.startsWith("java.")) return true;
if (pkg.startsWith("javax.")) return true;
return false;
}
protected int findErrorFile(int errorLine) {