Search in sources :

Example 1 with Encoder

use of com.intellij.flex.uiDesigner.abc.Encoder in project intellij-plugins by JetBrains.

the class LibrarySorter method sort.

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(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();
    }
}
Also used : ArrayList(java.util.ArrayList) Decoder(com.intellij.flex.uiDesigner.abc.Decoder) THashMap(gnu.trove.THashMap) Encoder(com.intellij.flex.uiDesigner.abc.Encoder)

Aggregations

Decoder (com.intellij.flex.uiDesigner.abc.Decoder)1 Encoder (com.intellij.flex.uiDesigner.abc.Encoder)1 THashMap (gnu.trove.THashMap)1 ArrayList (java.util.ArrayList)1