Package processing.app.debug

Examples of processing.app.debug.RunnerException


                                              name,
                                              codeFolderPackages);
    } catch (FileNotFoundException fnfe) {
      fnfe.printStackTrace();
      String msg = "Build folder disappeared or could not be written";
      throw new RunnerException(msg);
    }

    // 2. run preproc on that code using the sugg class name
    //    to create a single .java file and write to buildpath

    String primaryClassName = null;

    try {
      // if (i != 0) preproc will fail if a pde file is not
      // java mode, since that's required
      String className = preprocessor.write();

      if (className == null) {
        throw new RunnerException("Could not find main class");
        // this situation might be perfectly fine,
        // (i.e. if the file is empty)
        //System.out.println("No class found in " + code[i].name);
        //System.out.println("(any code in that file will be ignored)");
        //System.out.println();

//      } else {
//        code[0].setPreprocName(className + ".cpp");
      }

      // store this for the compiler and the runtime
      primaryClassName = className + ".cpp";

    } catch (FileNotFoundException fnfe) {
      fnfe.printStackTrace();
      String msg = "Build folder disappeared or could not be written";
      throw new RunnerException(msg);
    } catch (RunnerException pe) {
      // RunnerExceptions are caught here and re-thrown, so that they don't
      // get lost in the more general "Exception" handler below.
      throw pe;

    } catch (Exception ex) {
      // TODO better method for handling this?
      System.err.println("Uncaught exception type:" + ex.getClass());
      ex.printStackTrace();
      throw new RunnerException(ex.toString());
    }

    // grab the imports from the code just preproc'd

    importedLibraries = new ArrayList<File>();
    for (String item : preprocessor.getExtraImports()) {
      File libFolder = (File) Base.importToLibraryTable.get(item);

      if (libFolder != null && !importedLibraries.contains(libFolder)) {
        importedLibraries.add(libFolder);
        classPath += Compiler.contentsToClassPath(libFolder);
        libraryPath += File.pathSeparator + libFolder.getAbsolutePath();
      }
    }
 

/*
    importedLibraries = new ArrayList<Library>(); //new Vector();
    String imports[] = preprocessor.extraImports;
    try {
      LibraryManager libraryManager = new LibraryManager();
      Collection libraries = libraryManager.getAll();
      for (Iterator i = libraries.iterator(); i.hasNext(); ) {
        Library library = (Library) i.next();
        File[] headerFiles = library.getHeaderFiles();

        for (int j = 0; j < headerFiles.length; j++)
          for (int k = 0; k < imports.length; k++)
            if (headerFiles[j].getName().equals(imports[k]) &&
              !importedLibraries.contains(library)) {
              importedLibraries.add(library); //.getFolder());
              //System.out.println("Adding library " + library.getName());
            }
      }
    } catch (IOException e) {
      System.err.println("Error finding libraries:");
      e.printStackTrace();
      throw new RunnerException(e.getMessage());
    }
*/
    // 3. then loop over the code[] and save each .java file

    for (SketchCode sc : code) {
//      System.out.println(sc.getFileName());
      if (sc.isExtension("c") || sc.isExtension("cpp") || sc.isExtension("h")) {
        // no pre-processing services necessary for java files
        // just write the the contents of 'program' to a .java file
        // into the build directory. uses byte stream and reader/writer
        // shtuff so that unicode bunk is properly handled
        String filename = sc.getFileName(); //code[i].name + ".java";
        try {
          Base.saveFile(sc.getProgram(), new File(buildPath, filename));
        } catch (IOException e) {
          e.printStackTrace();
          throw new RunnerException("Problem moving " + filename +
                                    " to the build folder");
        }
//        sc.setPreprocName(filename);

      } else if (sc.isExtension("pde") || sc.isExtension("ino")) {
View Full Code Here


      SketchCode code = getCode(i);
      if (code.isExtension("cpp")||code.isExtension("h")||code.isExtension("c")) {
        if (dotJavaFilename.equals(code.getFileName())) {
          codeIndex = i;
          codeLine = dotJavaLine;
          return new RunnerException(message, codeIndex, codeLine);
        }
      }
    }
   
    // If not the preprocessed file at this point, then need to get out
    if (!dotJavaFilename.equals(name + ".cpp") && !dotJavaFilename.equals(name + ".c") && !dotJavaFilename.equals(name + ".h")) {
      return null;
    }
   
    // if it's not a .cpp or .c file, codeIndex will still be 0
    // this section searches through the list of .pde files
    codeIndex = 0;
    for (int i = 0; i < getCodeCount(); i++) {
      SketchCode code = getCode(i);
     
      if (code.isExtension("pde")) {
        //        System.out.println("preproc offset is " + code.getPreprocOffset());
        //        System.out.println("looking for line " + dotJavaLine);
        if (code.getPreprocOffset() <= dotJavaLine) {
          codeIndex = i;
          //          System.out.println("i'm thinkin file " + i);
          codeLine = dotJavaLine - code.getPreprocOffset();
        }
      }
    }
    // could not find a proper line number, so deal with this differently.
    // but if it was in fact the .java file we're looking for, though,
    // send the error message through.
    // this is necessary because 'import' statements will be at a line
    // that has a lower number than the preproc offset, for instance.
    //    if (codeLine == -1 && !dotJavaFilename.equals(name + ".java")) {
    //      return null;
    //    }
    return new RunnerException(message, codeIndex, codeLine);
  }
View Full Code Here

    } catch (RunnerException e) {
      System.err.println("Couldn't determine program size: " + e.getMessage());
    }
   
    if (size > maxsize)
      throw new RunnerException(
                                "Sketch too big. Try to reduce the size");
  }
View Full Code Here

TOP

Related Classes of processing.app.debug.RunnerException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.