if (problems.length != 0) {
System.err
.println("Resolve syntax errors before P5 preprocessor does its thing.");
return null;
}
PdePreprocessor preprocessor = new PdePreprocessor(editor.getSketch()
.getName());
String[] codeFolderPackages = null;
if (editor.getSketch().hasCodeFolder()) {
File codeFolder = editor.getSketch().getCodeFolder();
// javaLibraryPath = codeFolder.getAbsolutePath();
// get a list of .jar files in the "code" folder
// (class files in subfolders should also be picked up)
String codeFolderClassPath = Base.contentsToClassPath(codeFolder);
// append the jar files in the code folder to the class path
// classPath += File.pathSeparator + codeFolderClassPath;
// get list of packages found in those jars
codeFolderPackages = Base
.packageListFromClassPath(codeFolderClassPath);
} else {
// javaLibraryPath = "";
}
// String[] sizeInfo;
// try {
// sizeInfo = preprocessor.initSketchSize(editor.getSketch()
// .getCode(0).getProgram(), false);
// if (sizeInfo != null) {
// String sketchRenderer = sizeInfo[3];
// if (sketchRenderer != null) {
// if (sketchRenderer.equals("P2D")
// || sketchRenderer.equals("P3D")
// || sketchRenderer.equals("OPENGL")) {
// rawCode.insert(0, "import processing.opengl.*; ");
// }
// }
// }
//
// } catch (SketchException e) {
// System.err.println(e);
// }
// PdePreprocessor.parseSketchSize(sketch.getMainProgram(), false);
StringWriter writer = new StringWriter();
try {
PreprocessorResult result = preprocessor.write(writer,
rawCode.toString(), codeFolderPackages);
className = result.className;
prepareImports(result.extraImports);
sourceCode = writer.getBuffer().toString();
int position = sourceCode.indexOf("{");