Package org.sugarj.common.path

Examples of org.sugarj.common.path.RelativePath


  public RelativePath createCachePath(String relativePath) {
    return new RelativePath(cacheDir, relativePath);
  }
 
  public RelativePath createOutPath(String relativePath) {
    return new RelativePath(getBin(), relativePath);
  }
View Full Code Here


    if (!BaseLanguageRegistry.getInstance().isRegistered(FileCommands.getExtension(filename))) {
      Log.log.logErr("Unknown source-file extension " + FileCommands.getExtension(filename), Log.ALWAYS);
      return parseFailureResult(filename).getSugaredSyntaxTree();
    }

    RelativePath sourceFile = ModuleSystemCommands.locateSourceFile(filename, environment.getSourcePath());
    if (sourceFile == null)
      throw new IllegalArgumentException("Cannot find source file for path " + filename);
    this.sourceFile = sourceFile;
    String modulePath = FileCommands.dropExtension(sourceFile.getRelativePath());
    Result result = ModuleSystemCommands.locateResult(modulePath, environment);

    if (result == null)
      result = parseFailureResult(filename);
View Full Code Here

      index += "[writing".length();
      while (stdOut.charAt(index) == ' ')
        index++;
      int to = stdOut.indexOf(' ', index);
      String generatedPath = stdOut.substring(index, to);
      generatedFiles.add(new RelativePath(dir, generatedPath));
    }
   
    return generatedFiles;
  }
View Full Code Here

  private static Environment makeProjectEnvironment(IJavaProject project) throws JavaModelException {
    Environment env = new Environment(false, StdLib.stdLibDir);
   
    IPath fullPath = project.getProject().getFullPath();
    Path root = new AbsolutePath(project.getProject().getLocation().makeAbsolute().toString());
    Path bin = new RelativePath(root, project.getOutputLocation().makeRelativeTo(fullPath).toString());
    env.setRoot(root);
    env.setBin(bin);
   
    for (IPackageFragmentRoot fragment : project.getAllPackageFragmentRoots()) {
      IPath path = fragment.getPath();
      boolean externalPath = fragment.getResource() == null;
      String p = externalPath ? path.toString() : path.makeRelativeTo(fullPath).toString();

      Path includePath;
      if (fullPath.isPrefixOf(path))
        includePath = p.isEmpty() ? root : new RelativePath(root, p);
      else if (externalPath)
        includePath = new AbsolutePath(p);
      else
        includePath = new RelativePath(root, p);
     
      if (fragment.getKind() == IPackageFragmentRoot.K_SOURCE && fragment.getParent().equals(project))
        env.addToSourcePath(includePath);
      else if (fragment.getKind() == IPackageFragmentRoot.K_BINARY)
        env.addToIncludePath(includePath);
View Full Code Here

    return env;
  }
 
  private static void setDefaultEnvironmentOptions(Environment environment) {
    if (environment.getCacheDir() == null)
      environment.setCacheDir(new RelativePath(environment.getRoot(), ".sugarjcache"));

    environment.setAtomicImportParsing(true);
    environment.setNoChecking(true);
    environment.addToIncludePath(new AbsolutePath(new StrategoJarAntPropertyProvider().getAntPropertyValue("")));
  }
View Full Code Here

      e.printStackTrace();
    }
  }

  public static Path ensureFile(String resource) {
    Path f = new RelativePath(stdLibDir, resource);
    if (FileCommands.exists(f))
      return f;
   
    f = new RelativePath(stdLibTmpDir, resource);
    f.getFile().getParentFile().mkdirs();
   
    try {
      InputStream in = StdLib.class.getClassLoader().getResourceAsStream(resource);
      if (in == null)
        return new RelativePath(stdLibDir, resource);
     
      FileOutputStream fos = new FileOutputStream(f.getFile());
      int len = -1;
      byte[] bs = new byte[256];
      while ((len = in.read(bs)) >= 0)
        fos.write(bs, 0, len);
      fos.close();
View Full Code Here

   * @param hash
   * @return
   * @throws IOException
   */
  public static Path createFile(Path dir, int hash) throws IOException {
    Path p = new RelativePath(dir, hashFileName("sugarj", hash));
    createFile(p);
    return p;
  }
View Full Code Here

   * @param hash
   * @return
   * @throws IOException
   */
  public static Path createDir(Path dir, int hash) throws IOException {
    Path p = new RelativePath(dir, hashFileName("SugarJ", hash));
    createDir(p);
    return p;
  }
View Full Code Here

   
    return file;
  }

  public static RelativePath dropFilename(RelativePath file) {
    return new RelativePath(file.getBasePath(), dropFilename(file.getRelativePath()));
  }
View Full Code Here

   
    String baseS = base.getAbsolutePath();
    String fullS = fullPath.getAbsolutePath();
   
    if (fullS.startsWith(baseS))
      return new RelativePath(base, fullS.substring(baseS.length()));
   
    return null;
  }
View Full Code Here

TOP

Related Classes of org.sugarj.common.path.RelativePath

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.