Package org.sugarj.common.path

Examples of org.sugarj.common.path.RelativePath


   
    return libDir;
  }

  public Path ensureFile(String resource) {
    Path f = new RelativePath(getPluginDirectory(), resource);
 
    if (FileCommands.exists(f))
      return f;
 
    if (libTmpDir == null) {
      try {
        libTmpDir = FileCommands.newTempDir();
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
 
    f = new RelativePath(libTmpDir, resource);
    f.getFile().getParentFile().mkdirs();
 
    try {
      InputStream in = this.getClass().getClassLoader().getResourceAsStream(resource);
      if (in == null) {
        Log.log.logErr("Could not load resource " + resource, Log.ALWAYS);
        return new RelativePath(getPluginDirectory(), 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


    String declaredModuleName = FileCommands.fileName(qualifiedModulePath);
    moduleName = FileCommands.dropExtension(FileCommands.fileName(sourceFile.getRelativePath()));
    String declaredRelNamespaceName = FileCommands.dropFilename(qualifiedModulePath);
    relNamespaceName = FileCommands.dropFilename(sourceFile.getRelativePath());
   
    RelativePath objectFile = environment.createOutPath(getRelativeNamespaceSep() + moduleName + "." + getLanguage().getBinaryFileExtension());
    generatedModules.add(objectFile);
   
    moduleHeader = prettyPrint(toplevelDecl);
   
    if (!declaredRelNamespaceName.equals(relNamespaceName))
View Full Code Here

 
  @Override
  public List<Path> compile(List<Path> outFiles, Path bin, List<Path> includePaths) throws IOException {
    List<Path> generatedFiles = new LinkedList<Path>();
    for (Path out : outFiles) {
      RelativePath relOut = (RelativePath) out;
      Path compilePath = new RelativePath(bin, FileCommands.dropExtension(relOut.getRelativePath()) + ".pts");
      FileCommands.copyFile(out, compilePath);
      generatedFiles.add(compilePath);
    }
    return generatedFiles;
  }
View Full Code Here

    String declaredModuleName = FileCommands.fileName(qualifiedModulePath);
    moduleName = FileCommands.dropExtension(FileCommands.fileName(sourceFile.getRelativePath()));
    String declaredRelNamespaceName = FileCommands.dropFilename(qualifiedModulePath);
    relNamespaceName = FileCommands.dropFilename(sourceFile.getRelativePath());
   
    RelativePath objectFile = environment.createOutPath(getRelativeNamespaceSep() + moduleName + "." + HaskellLanguage.getInstance().getBinaryFileExtension());
    generatedModules.add(objectFile);
   
    moduleHeader = prettyPrint(toplevelDecl);
   
    if (!declaredRelNamespaceName.equals(relNamespaceName))
View Full Code Here

        @Override
        public boolean visit(IResource resource) throws CoreException {
          Path root = new AbsolutePath(getProject().getLocation().makeAbsolute().toString());
          IPath relPath = resource.getFullPath().makeRelativeTo(getProject().getFullPath());
          if (!relPath.isEmpty() &&
              (environment.getParseBin().equals(new RelativePath(root, relPath.toString())) ||
               environment.getIncludePath().contains(new RelativePath(root, relPath.toString()))))
            return false;
         
          if (languageReg.isRegistered(resource.getFileExtension())) {
            String path = getProject().getLocation().makeAbsolute() + "/" + relPath;
            final RelativePath sourceFile = ModuleSystemCommands.locateSourceFile(
                    path.toString(),
                    environment.getSourcePath());
           
            if (sourceFile == null) {
//              org.strategoxt.imp.runtime.Environment.logWarning("cannot locate source file for ressource " + resource.getFullPath());
View Full Code Here

              return Status.CANCEL_STATUS;
            }
             
            monitor.beginTask("compile " + input.sourceFile.getRelativePath(), IProgressMonitor.UNKNOWN);

            RelativePath depFile = new RelativePath(environment.getParseBin(), FileCommands.dropExtension(input.sourceFile.getRelativePath()) + ".dep");
            Result res = Result.readDependencyFile(depFile);
            if (res == null || !res.isUpToDate(input.sourceFile, environment))
              res = Driver.run(input.sourceFile, environment, monitor, input.baseLang);
           
            IWorkbenchWindow[] workbenchWindows = PlatformUI.getWorkbench().getWorkbenchWindows();
View Full Code Here

   
    try {
      String[] sources = DriverCLI.handleOptions(args, environment);
     
      for (String source : sources) {
        RelativePath sourceLocation = ModuleSystemCommands.locateSourceFile(source, environment.getSourcePath());
       
        if (sourceLocation == null) {
          Log.log.logErr("Could not locate source file \"" + source +"\".", Log.ALWAYS);
          continue;
        }
View Full Code Here

 
  // without running eclipse platform,
  // set up a default environment reasonable for command-line execution.
  private static Environment getConsoleEnvironment() {
    Environment environment = new Environment(true, StdLib.stdLibDir);
    environment.setCacheDir(new RelativePath(new AbsolutePath(FileCommands.TMP_DIR), ".sugarjcache"));
    environment.addToSourcePath(new AbsolutePath("."));
    environment.setAtomicImportParsing(true);
    environment.setNoChecking(true);
   
    for (String cp : System.getProperty("java.class.path").split(System.getProperty("path.separator"))) {
View Full Code Here

    public static RelativePath importBinFile(String modulePath, Environment environment, AbstractBaseProcessor baseProcessor, Result driverResult) throws IOException {
      String ext = baseProcessor.getLanguage().getBinaryFileExtension();
      if (ext != null)
        // language is interpreted
        ext = baseProcessor.getLanguage().getBaseFileExtension();
      RelativePath clazz = searchFile(modulePath, ext, environment, driverResult);
      if (clazz == null)
        return null;
     
      log.log("Found language-specific declaration for " + modulePath, Log.IMPORT);
      return clazz;
View Full Code Here

   * @param driverResult
   * @return path to new grammar or null if no sdf file existed.
   * @throws IOException
   */
  public static RelativePath importSdf(String modulePath, Environment environment, Result driverResult) {
    RelativePath sdf = searchFile(modulePath, "sdf", environment, driverResult);
   
    if (sdf == null)
      return null;
   
    log.log("Found syntax definition for " + modulePath, Log.IMPORT);
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.