コード例 #1
0
  /**
   * @param newAST
   * @param fullPath
   * @param iPath
   */
  public static void storeNewAST(
      CompilationUnit newAST, IPath projectPath, IPath relativeResourcePath) {
    try {
      /*IPath path = fullPath.addFileExtension(extension);

      File file = path.toFile();// new File(path.toString());
      // file.createNewFile();*/
      File file = getFileLocation(projectPath.toOSString(), relativeResourcePath.toOSString());
      file.getParentFile().mkdirs();
      file.createNewFile();

      // System.out.println(file.getAbsolutePath());

      FileWriter fstream = new FileWriter(file);
      BufferedWriter out = new BufferedWriter(fstream);

      out.write(newAST.toString());
      out.close();

    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
コード例 #2
0
ファイル: AbstractJavaSource.java プロジェクト: ahmedae/core
  /** Return this {@link JavaSource} file as a String */
  @Override
  public String toString() {
    Document document = new Document(this.document.get());

    try {
      TextEdit edit = unit.rewrite(document, null);
      edit.apply(document);
    } catch (Exception e) {
      throw new ParserException("Could not modify source: " + unit.toString(), e);
    }

    return Formatter.format(document.get());
  }