Ejemplo n.º 1
0
  @NotNull
  public ValueContainerImpl<Value> copy() {
    ValueContainerImpl<Value> container = new ValueContainerImpl<Value>();

    if (myInputIdMapping instanceof THashMap) {
      final THashMap<Value, Object> mapping = (THashMap<Value, Object>) myInputIdMapping;
      final THashMap<Value, Object> newMapping = new THashMap<Value, Object>(mapping.size());
      container.myInputIdMapping = newMapping;

      mapping.forEachEntry(
          new TObjectObjectProcedure<Value, Object>() {
            @Override
            public boolean execute(Value key, Object val) {
              if (val instanceof ChangeBufferingList) {
                newMapping.put(key, ((ChangeBufferingList) val).clone());
              } else {
                newMapping.put(key, val);
              }
              return true;
            }
          });
    } else {
      container.myInputIdMapping = myInputIdMapping;
      container.myInputIdMappingValue =
          myInputIdMappingValue instanceof ChangeBufferingList
              ? ((ChangeBufferingList) myInputIdMappingValue).clone()
              : myInputIdMappingValue;
    }
    return container;
  }
Ejemplo n.º 2
0
  private void removeValue(int inputId, Value value) {
    final Object input = getInput(value);
    if (input == null) {
      return;
    }

    if (input instanceof ChangeBufferingList) {
      final ChangeBufferingList changesList = (ChangeBufferingList) input;
      changesList.remove(inputId);
      if (!changesList.isEmpty()) return;
    } else if (input instanceof Integer) {
      if (((Integer) input).intValue() != inputId) {
        return;
      }
    }

    if (!(myInputIdMapping instanceof THashMap)) {
      myInputIdMapping = null;
      myInputIdMappingValue = null;
    } else {
      THashMap<Value, Object> mapping = (THashMap<Value, Object>) myInputIdMapping;
      mapping.remove(value);
      if (mapping.size() == 1) {
        myInputIdMapping = mapping.keySet().iterator().next();
        myInputIdMappingValue = mapping.get((Value) myInputIdMapping);
      }
    }
  }
Ejemplo n.º 3
0
  public SortResult sort(
      List<Library> libraries,
      File outFile,
      Condition<String> isExternal,
      boolean returnDefinitionMap)
      throws IOException {
    final THashMap<CharSequence, Definition> definitionMap =
        new THashMap<>(libraries.size() * 128, AbcTranscoder.HASHING_STRATEGY);
    final List<LibrarySetItem> unsortedItems = collectItems(libraries, definitionMap, isExternal);
    final AbcMerger abcMerger = new AbcMerger(definitionMap, outFile, definitionProcessor);
    try {
      final ArrayList<Library> resourceOrStyleHolders = new ArrayList<>(unsortedItems.size());
      for (LibrarySetItem item : unsortedItems) {
        if (!item.hasDefinitions()) {
          if (item.library.hasResourceBundles()) {
            resourceOrStyleHolders.add(item.library);
          }
          continue;
        }

        if (item.library.hasResourceBundles() || item.library.isStyleOwner()) {
          resourceOrStyleHolders.add(item.library);
        }

        abcMerger.process(item.library);
      }

      if (definitionMapProcessor != null) {
        definitionMapProcessor.process(definitionMap, abcMerger);
      }

      final List<Decoder> decoders = new ArrayList<>(definitionMap.size());
      final String[] singleStringArray = new String[1];
      definitionMap.forEachValue(
          new TObjectProcedure<Definition>() {
            @Override
            public boolean execute(Definition definition) {
              if (definition.doAbcData != null
                  && (definition.resolved == ResolvedState.YES
                      || (definition.resolved == ResolvedState.UNKNOWN
                          && processDependencies(
                              decoders, definition, definitionMap, singleStringArray)))) {
                decoders.add(createDecoder(definition));
              }

              return true;
            }
          });

      abcMerger.end(decoders, new Encoder());
      return new SortResult(returnDefinitionMap ? definitionMap : null, resourceOrStyleHolders);
    } finally {
      abcMerger.close();
    }
  }
 public int size() {
   return myRegularMap.size() + myForeignMap.size() + myOtherMap.size();
 }