Package org.sugarj.common.path

Examples of org.sugarj.common.path.RelativePath


   
    return null;
  }
 
  public static Path tryCopyFile(Path from, Path to, Path file) throws IOException {
    RelativePath p = getRelativePath(from, file);
    Path target = file;
    if (p != null) {
      target = new RelativePath(to, p.getRelativePath());
      copyFile(p, target);
    }
    return target;
  }
View Full Code Here


  @Override
  public boolean call(IContext context, Strategy[] svars, IStrategoTerm[] tvars) throws InterpreterException {
    IStrategoTerm generatedModel = context.current();
   
    String modelPath = ATermCommands.getString(tvars[0]);
    RelativePath modelRelativePath = new RelativePath(modelPath);
   
    IStrategoTerm transformationsTerm = tvars[1];
    RelativePath transformationPath = new RelativePath(ATermCommands.getString(transformationsTerm));
   
    RelativePath source = ImportCommands.getTransformedModelSourceFilePath(modelRelativePath, transformationPath, environment);
   
    try {
      Renaming ren = new Renaming(modelPath, source.getRelativePath());
      environment.getRenamings().add(0, ren);
//      generatedModel = driver.currentRename(generatedModel);
     
      driver.getCurrentResult().generateFile(source, ATermCommands.atermToString(generatedModel));
    } catch (IOException e) {
View Full Code Here

     
      if (!ATermCommands.isString(tvars[0]) || !ATermCommands.isString(tvars[1]))
        return false;
     
      String modelPath = ATermCommands.getString(tvars[0]);
      RelativePath modelRelativePath = new RelativePath(modelPath);
     
      IStrategoTerm transformationsTerm = tvars[1];
      RelativePath transformationPath = new RelativePath(ATermCommands.getString(transformationsTerm));
     
      RelativePath source = ImportCommands.getTransformedModelSourceFilePath(modelRelativePath, transformationPath, environment);
     
      try {
        Renaming ren = new Renaming(modelPath, source.getRelativePath());
        environment.getRenamings().add(0, ren);
//        generatedModel = driver.currentRename(generatedModel);
       
        driver.getCurrentResult().generateFile(source, ATermCommands.atermToString(generatedModel));
      } catch (IOException e) {
        driver.setErrorMessage(e.getLocalizedMessage());
      }
     
      Result res;
      try {
        res = driver.subcompile(driver.getTreeForErrorMarking(), source);
       
        if (res != null) {
          context.setCurrent(ATermCommands.atermFromFile(source.getAbsolutePath()));
         
          Result modelResult = ModuleSystemCommands.locateResult(FileCommands.dropExtension(modelPath), environment);
          if (modelResult != null)
            res.addDependency(modelResult);
          Result transformationResult = ModuleSystemCommands.locateResult(FileCommands.dropExtension(transformationPath.getRelativePath()), environment);
View Full Code Here

    for (Entry<Path, Integer> e : generatedFileHashes.entrySet()) {
      Path p = FileCommands.tryCopyFile(parseResultPath, targetDir, e.getKey());
      res.logFileGeneration(p, FileCommands.fileHash(p));
    }
   
    RelativePath wasDep = FileCommands.getRelativePath(parseResultPath, persistentPath);
    Path dep = persistentPath;
    if (wasDep != null)
      dep = new RelativePath(targetDir, wasDep.getRelativePath());
   
    res.writeDependencyFile(dep);
   
    return res;
  }
View Full Code Here

    } catch (Exception e) {
      org.strategoxt.imp.runtime.Environment.logException(e);
    } finally {
      pendingRuns.remove(sourceFile);
      if (!driver.environment.doGenerateFiles()) {
        Path binDep = new RelativePath(driver.environment.getCompileBin(), modulePath + ".dep");
        Result.cacheInMemory(binDep, driver.driverResult);
      }
    }

    return driver.driverResult;
View Full Code Here

  private void processEditorServices(String extName, IStrategoTerm services) throws IOException {
    if (!ATermCommands.isList(services))
      throw new IllegalStateException("editor services are not a list: " + services);
   
    RelativePath editorServicesFile = environment.createOutPath(baseProcessor.getRelativeNamespaceSep() + extName + ".serv");
    List<IStrategoTerm> editorServices = ATermCommands.getList(services);
   
    log.log("writing editor services to " + editorServicesFile, Log.DETAIL);
   
    StringBuffer buf = new StringBuffer();
View Full Code Here

        return;
     
      String plainContent = Term.asJavaString(ATermCommands.getApplicationSubterm(body, "PlainBody", 0));
     
      String ext = extension == null ? "" : ("." + extension);
      RelativePath plainFile = environment.createOutPath(baseProcessor.getRelativeNamespaceSep() + extName + ext);
      FileCommands.createFile(plainFile);

      log.log("writing plain content to " + plainFile, Log.DETAIL);
      driverResult.generateFile(plainFile, plainContent);
    } finally {
View Full Code Here

  protected boolean prepareImport(IStrategoTerm toplevelDecl, String modulePath) throws IOException, TokenExpectedException, ParseException, InvalidParseTableException, SGLRException, InterruptedException {
    boolean isCircularImport = false;
   
    if (!modulePath.startsWith("org/sugarj")) { // module is not in sugarj standard library
      Result res = ModuleSystemCommands.locateResult(modulePath, environment);
      RelativePath importSourceFile;
      if (res != null && res.getSourceFile() != null)
        importSourceFile = res.getSourceFile();
      else
        importSourceFile = ModuleSystemCommands.locateSourceFileOrModel(modulePath, environment.getSourcePath(), baseProcessor, environment);
View Full Code Here

   
    return success;
  }
 
  private boolean processModelImport(String modulePath) throws IOException {
    RelativePath model = ModuleSystemCommands.importModel(modulePath, environment, driverResult);
    if (model != null) {
//      availableModels.add(model);
      return true;
    }
   
View Full Code Here

      log.log("The full name of the sugar is '" + fullExtName + "'.", Log.DETAIL);
     
      if (dependsOnModel)
        return;
     
      RelativePath sdfExtension = environment.createOutPath(baseProcessor.getRelativeNamespaceSep() + extName + ".sdf");
      RelativePath strExtension = environment.createOutPath(baseProcessor.getRelativeNamespaceSep() + extName + ".str");
     
      String sdfImports = " imports " + StringCommands.printListSeparated(availableSDFImports, " ") + "\n";
      String strImports = " imports " + StringCommands.printListSeparated(availableSTRImports, " ") + "\n";
     
      // this is a list of SDF and Stratego statements
     
      IStrategoTerm extensionBody = baseProcessor.getExtensionBody(toplevelDecl);

      IStrategoTerm sdfExtract = fixSDF(extractSDF(extensionBody), baseProcessor.getInterpreter());
      IStrategoTerm strExtract = extractSTR(extensionBody);
      IStrategoTerm editorExtract = extractEditor(extensionBody);
     
      String sdfExtensionHead =
        "module " + fullExtName + "\n"
        + sdfImports
        + "exports " + "\n"
        + "  (/)" + "\n";

      String sdfExtensionContent = SDFCommands.prettyPrintSDF(sdfExtract, baseProcessor.getInterpreter());

      String sdfSource = SDFCommands.makePermissiveSdf(sdfExtensionHead + sdfExtensionContent);
      driverResult.generateFile(sdfExtension, sdfSource);
      availableSDFImports.add(fullExtName);
     
      if (CommandExecution.FULL_COMMAND_LINE)
        log.log("Wrote SDF file to '" + sdfExtension.getAbsolutePath() + "'.", Log.DETAIL);
     
      String strExtensionTerm = "Module(" + "\"" + fullExtName+ "\"" + ", " + strExtract + ")" + "\n";
//      try {
//        strExtensionTerm = STRCommands.assimilate("strip-annos", currentTransProg, strExtensionTerm, langLib.getInterpreter());
//      } catch (Exception e) {
//        e.printStackTrace();
//      }
//      String strExtensionContent = SDFCommands.prettyPrintSTR(strExtensionTerm, langLib.getInterpreter());
      String strExtensionContent = SDFCommands.prettyPrintSTR(ATermCommands.atermFromString(strExtensionTerm), baseProcessor.getInterpreter());
     
      int index = strExtensionContent.indexOf('\n');
      if (index >= 0)
        strExtensionContent =
          strExtensionContent.substring(0, index + 1) + "\n"
          + strImports + "\n"
          + strExtensionContent.substring(index + 1);
      else
        strExtensionContent += strImports;
       
     
      driverResult.generateFile(strExtension, strExtensionContent);
      availableSTRImports.add(fullExtName);
     
      if (CommandExecution.FULL_COMMAND_LINE)
        log.log("Wrote Stratego file to '" + strExtension.getAbsolutePath() + "'.", Log.DETAIL);
     
      processEditorServices(extName, editorExtract);
     
      /*
       * adapt current grammar
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.