Esempio n. 1
0
  public static GenerationDependencies fromIncremental(
      Map<SNode, SNode> currentToOriginalMap,
      RootDependenciesBuilder[] roots,
      String modelHash,
      String parametersHash,
      IOperationContext operationContext,
      IncrementalGenerationStrategy incrementalStrategy,
      int skippedCount,
      int fromCacheCount) {
    Map<String, List<String>> generatedFiles = getGeneratedFiles(currentToOriginalMap);

    List<GenerationRootDependencies> unchanged = null;
    List<GenerationRootDependencies> rootDependencies =
        new ArrayList<GenerationRootDependencies>(roots.length);
    Map<String, String> externalHashes = new HashMap<String, String>();
    for (RootDependenciesBuilder l : roots) {
      SNode originalRoot = l.getOriginalRoot();
      List<String> files = generatedFiles.get(originalRoot != null ? originalRoot.getId() : "");
      if (files == null) {
        files = Collections.emptyList();
      }
      GenerationRootDependencies dep;
      if (l.isUnchanged()) {
        dep = l.getSavedDependencies();
        if (unchanged == null) {
          unchanged = new ArrayList<GenerationRootDependencies>();
        }
        unchanged.add(dep);
      } else {
        dep = GenerationRootDependencies.fromData(l, files);
      }
      rootDependencies.add(dep);
      for (String modelReference : dep.getExternal()) {
        if (!externalHashes.containsKey(modelReference)) {
          SModelDescriptor sm =
              SModelRepository.getInstance()
                  .getModelDescriptor(SModelReference.fromString(modelReference));
          Map<String, String> hashes = incrementalStrategy.getModelHashes(sm, operationContext);
          String value = hashes != null ? hashes.get(ModelDigestHelper.FILE) : null;
          externalHashes.put(modelReference, value);
        }
      }
    }
    return new GenerationDependencies(
        rootDependencies,
        modelHash,
        parametersHash,
        externalHashes,
        unchanged == null ? Collections.<GenerationRootDependencies>emptyList() : unchanged,
        skippedCount,
        fromCacheCount);
  }
Esempio n. 2
0
  public synchronized Set<SModelReference> resolveModel(
      SModule module, String name, @Nullable SNodeId nodeId) {
    Pair<SModuleReference, String> key =
        new Pair<SModuleReference, String>(module.getModuleReference(), name);
    ensureInitialized(key);

    Set<SModelReference> models = myStubModulesCache.get(key);
    if (nodeId == null) return new HashSet<SModelReference>(models);

    Set<SModelReference> result = new HashSet<SModelReference>();
    for (SModelReference ref : models) {
      SModel m = SModelRepository.getInstance().getModelDescriptor(ref);
      if (m.getNode(nodeId) != null) {
        result.add(ref);
      }
    }

    return result;
  }