@@ -0,0 +1,2865 @@
+package org.sugarj.common;%0A%0Aimport java.io.Serializable;%0Aimport java.util.LinkedList;%0Aimport java.util.List;%0A%0Aimport org.spoofax.interpreter.library.ssl.StrategoHashMap;%0Aimport org.spoofax.interpreter.terms.IStrategoTerm;%0Aimport org.sugarj.common.path.RelativePath;%0A%0A/**%0A * @author Sebastian Erdweg%0A */%0Apublic class Renaming %7B%0A  public static class FromTo implements Serializable %7B%0A    private static final long serialVersionUID = -3707638775569347652L;%0A%0A    public List%3CString%3E pkgs;%0A    public String from;%0A    public String to;%0A    %0A    public FromTo(List%3CString%3E pkgs, String from, String to) %7B%0A      this.pkgs = pkgs;%0A      this.from = from;%0A      this.to = to;%0A    %7D%0A%0A    public FromTo(RelativePath fromPath, RelativePath toPath) %7B%0A      this(fromPath.getRelativePath(), toPath.getRelativePath());%0A    %7D%0A    %0A    public FromTo(String fromPath, String toPath) %7B%0A      this.from = FileCommands.fileName(fromPath).replace(%22-%22, %22$%22);%0A      this.to = FileCommands.fileName(toPath).replace(%22-%22, %22$%22);%0A      this.pkgs = new LinkedList%3CString%3E();%0A      for (String pkg : fromPath.split(Environment.sep))%0A        this.pkgs.add(pkg);%0A      this.pkgs.remove(this.pkgs.size() - 1);%0A    %7D%0A  %7D%0A%0A  %0A  public static IStrategoTerm makeRenamingHashtable(List%3CFromTo%3E renamings) %7B%0A    StrategoHashMap map = new StrategoHashMap(renamings.size(), Math.max(1, renamings.size()));%0A    %0A    for (FromTo r : renamings) %7B%0A      List%3CIStrategoTerm%3E qualTerms = new LinkedList%3CIStrategoTerm%3E();%0A      for (String qual : r.pkgs)%0A        qualTerms.add(ATermCommands.makeString(qual));%0A      IStrategoTerm quals = ATermCommands.makeList(%22Qualifiers%22, qualTerms);%0A      IStrategoTerm from = ATermCommands.makeString(r.from);%0A      IStrategoTerm to = ATermCommands.makeString(r.to);%0A      %0A      if (!map.containsKey(from))%0A        map.put(from, to);%0A      if (!map.containsKey(ATermCommands.makeTuple(quals, from)))%0A      map.put(ATermCommands.makeTuple(quals, from), to);%0A    %7D%0A    %0A    return ATermCommands.makeAppl(%22Hashtable%22, %22%22, 1, map);%0A  %7D%0A  %0A  /**%0A   * Computes the path of the model file generated from the given model path by the given transformation path.%0A   * %0A   * @param modelPath%0A   * @param transformationPath%0A   * @param environment%0A   * @return%0A   */%0A  public static RelativePath getTransformedModelSourceFilePath(RelativePath modelPath, RelativePath transformationPath, Environment environment) %7B%0A    if (modelPath == null)%0A      return null;%0A    if (transformationPath == null)%0A      return environment.createOutPath(modelPath + %22.model%22);%0A    %0A    String transformationPathString = FileCommands.dropExtension(transformationPath.getRelativePath());%0A    String transformedModelPath = FileCommands.dropExtension(modelPath.getRelativePath()) + %22__%22 + transformationPathString.replace('/', '_');%0A    return environment.createOutPath(transformedModelPath + %22.model%22);%0A  %7D%0A%0A%7D%0A

improve renaming