Package org.sugarj.common.path

Examples of org.sugarj.common.path.Path


    LinkedList<Path> queue = new LinkedList<Path>();
    queue.add(persistentPath);
    visited.add(persistentPath);
   
    while (!queue.isEmpty()) {
      Path dep = queue.pop();
      Result res = readDependencyFile(dep);
     
      for (Path p : res.generatedFileHashes.keySet())
        if (!dependencies.contains(p) && FileCommands.exists(p))
          dependencies.add(p);
View Full Code Here


    Set<Path> checked = new HashSet<Path>();
    Set<Path> dependends = new HashSet<Path>(dependencies.keySet());
   
    while (!dependends.isEmpty()) {
      Path path = dependends.iterator().next();
      dependends.remove(path);
     
      if (checked.contains(path))
        continue;
     
View Full Code Here

    res.parseTableFile = FileCommands.tryCopyFile(parseResultPath, targetDir, parseTableFile);
    res.generationLog = FileCommands.tryCopyFile(parseResultPath, targetDir, generationLog);

    res.generatedFileHashes = new HashMap<Path, Integer>(generatedFileHashes.size());
    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);
   
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

      driverResult.setSourceFile(this.sourceFile, declProvider.getSourceHashCode());
     
      baseProcessor.init(sourceFile, environment);

      depOutFile = environment.createOutPath(FileCommands.dropExtension(sourceFile.getRelativePath()) + ".dep");
      Path genLog = environment.createOutPath(FileCommands.dropExtension(sourceFile.getRelativePath()) + ".gen");
      driverResult.setGenerationLog(genLog);
      // clearGeneratedStuff();

      initEditorServices();
View Full Code Here

      }
      else if (baseLanguage.isBaseDecl(toplevelDecl)) {
        List<String> additionalModules = processLanguageDec(toplevelDecl);
        for (String module : additionalModules) {
          prepareImport(toplevelDecl, module);
          Path clazz = ModuleSystemCommands.importBinFile(module, environment, baseProcessor, driverResult);
          if (clazz == null)
            setErrorMessage(toplevelDecl, "Could not resolve required module " + module);
        }
      }
      else if (baseLanguage.isExtensionDecl(toplevelDecl))
View Full Code Here

  }
 
  private boolean processImport(String modulePath, IStrategoTerm importTerm) throws IOException {
    boolean success = false;
   
    Path clazz = ModuleSystemCommands.importBinFile(modulePath, environment, baseProcessor, driverResult);
    if (clazz != null || baseProcessor.isModuleExternallyResolvable(modulePath)) {
      success = true;
      baseProcessor.processModuleImport(importTerm);
    }

    Path sdf = ModuleSystemCommands.importSdf(modulePath, environment, driverResult);
    if (sdf != null) {
      success = true;
      availableSDFImports.add(modulePath);
      buildCompoundSdfModule();
    }
   
    Path str = ModuleSystemCommands.importStratego(modulePath, environment, driverResult);
    if (str != null) {
      success = true;
      availableSTRImports.add(modulePath);
      buildCompoundStrModule();
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  private static synchronized void initializeCaches(Environment environment, boolean force) throws IOException {
    if (environment.getCacheDir() == null)
      return;
   
    Path stdlibVersion = environment.createCachePath("version");
    if (!stdlibVersion.getFile().exists() || !FileCommands.readFileAsString(stdlibVersion).equals(StdLib.VERSION)) {
      for (File f : environment.getCacheDir().getFile().listFiles())
        f.delete();
      FileCommands.writeToFile(stdlibVersion, StdLib.VERSION);
    }
   
    Path sdfCachePath = environment.createCachePath("sdfCaches");
    Path strCachePath = environment.createCachePath("strCaches");
   
    if (sdfCaches == null || force)
      sdfCaches = new HashMap<Path, Map<String,ModuleKeyCache<Path>>>();
    if (strCaches == null || force)
      strCaches = new HashMap<Path, Map<String, ModuleKeyCache<Path>>>();
   
    ObjectInputStream sdfIn = null;
    ObjectInputStream strIn = null;
    try{
      sdfIn = new ObjectInputStream(new FileInputStream(sdfCachePath.getFile()));
      if (!sdfCaches.containsKey(environment.getCacheDir())) {
        Map<String, ModuleKeyCache<Path>> sdfLocalCaches = (Map<String, ModuleKeyCache<Path>>) sdfIn.readObject();
        sdfCaches.put(environment.getCacheDir(), sdfLocalCaches);
      }
      strIn = new ObjectInputStream(new FileInputStream(strCachePath.getFile()));
      if (!strCaches.containsKey(environment.getCacheDir())) {
        Map<String, ModuleKeyCache<Path>> strLocalCaches = (Map<String, ModuleKeyCache<Path>>) strIn.readObject();
        strCaches.put(environment.getCacheDir(), strLocalCaches);
      }
    } catch (Exception e) {
View Full Code Here

  private static ModuleKeyCache<Path> selectCache(Map<Path, Map<String, ModuleKeyCache<Path>>> caches, AbstractBaseLanguage baseLang, Environment environment) throws IOException {
    if (caches == null)
      return null;
    synchronized (caches) {
      ModuleKeyCache<Path> cache = caches.get(environment.getCacheDir()).get(baseLang.getLanguageName());
      Path versionPath = environment.createCachePath(baseLang.getLanguageName() + ".version");
      if (cache != null &&
          (!FileCommands.exists(versionPath) || !baseLang.getVersion().equals(FileCommands.readFileAsString(versionPath))))
        cache = null;
      if (cache == null) {
        cache = new ModuleKeyCache<Path>(caches);
View Full Code Here

  private static synchronized void storeCaches(Environment environment) throws IOException {
    if (environment.getCacheDir() == null)
      return;
   
    Path cacheVersion = environment.createCachePath("version");
    FileCommands.writeToFile(cacheVersion, StdLib.VERSION);
   
    Path sdfCachePath = environment.createCachePath("sdfCaches");
    Path strCachePath = environment.createCachePath("strCaches");

    if (!sdfCachePath.getFile().exists())
      FileCommands.createFile(sdfCachePath);

    if (!strCachePath.getFile().exists())
      FileCommands.createFile(strCachePath);
   
    if (sdfCaches != null) {
      ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(sdfCachePath.getFile()));
      try {
        oos.writeObject(sdfCaches.get(environment.getCacheDir()));
      } finally {
        oos.close();
      }
    }
   
    if (strCaches != null) {
      ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(strCachePath.getFile()));
      try {
        oos.writeObject(strCaches.get(environment.getCacheDir()));
      } finally {
        oos.close();
      }
View Full Code Here

TOP

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

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.