Пример #1
0
 public ITernModule getTernModule(String moduleName) throws TernException {
   for (ITernModule module : workingCopyModules) {
     if (moduleName.equals(module.getName())) {
       return module;
     }
   }
   return null;
 }
Пример #2
0
 public boolean hasCheckedTernModule(String moduleName) {
   for (ITernModule checkedModule : checkedModules) {
     if (moduleName.equals(checkedModule.getName())) {
       return true;
     }
   }
   return false;
 }
Пример #3
0
  @Override
  public void commit(Object caller) throws IOException {
    removeCaller(caller);
    if (isDirty()) {
      try {
        // save tern project with updated tern modules
        ITernRepository repository = project.getRepository();
        // clear Plugin + JSON Type Definition
        project.clearPlugins();
        project.clearLibs();
        // Add Plugin + JSON Type Definition
        Collection<String> requiredDependencies = null;
        ITernModule dependencyModule = null;
        List<ITernModule> sortedModules = new ArrayList<ITernModule>();
        for (ITernModule module : this.getCheckedModules()) {
          TernModuleMetadata metadata = module.getMetadata();
          if (metadata != null) {
            // add required dependencies (ex : if ecma6 is checked,
            // ecma5 must
            // be added too).
            requiredDependencies = metadata.getRequiredDependencies(module.getVersion());
            for (String dependency : requiredDependencies) {
              dependencyModule = repository.getModule(dependency);
              if (dependencyModule != null && !sortedModules.contains(dependencyModule)) {
                sortedModules.add(dependencyModule);
              }
            }
          }
          if (module != null && !sortedModules.contains(module)) {
            sortedModules.add(module);
          }
        }
        TernModuleHelper.sort(sortedModules);
        for (ITernModule m : sortedModules) {
          TernModuleHelper.update(m, project);
        }
        project.save();

      } finally {
        clear();
      }
    }
  }