Search in sources :

Example 1 with FlexLibrarySet

use of com.intellij.flex.uiDesigner.libraries.FlexLibrarySet in project intellij-plugins by JetBrains.

the class ComplexRenderAction method updateLocalStyleSources.

private void updateLocalStyleSources(final Client client, final THashMap<ModuleInfo, List<LocalStyleHolder>> localStyleSources) {
    final ProblemsHolder problemsHolder = new ProblemsHolder();
    final ProjectComponentReferenceCounter projectComponentReferenceCounter = new ProjectComponentReferenceCounter();
    localStyleSources.forEachEntry(new TObjectObjectProcedure<ModuleInfo, List<LocalStyleHolder>>() {

        @Override
        public boolean execute(ModuleInfo moduleInfo, List<LocalStyleHolder> b) {
            try {
                List<LocalStyleHolder> oldList = moduleInfo.getLocalStyleHolders();
                if (oldList == null) {
                    oldList = Collections.emptyList();
                }
                FlexLibrarySet flexLibrarySet = moduleInfo.getFlexLibrarySet();
                final StringRegistry.StringWriter stringWriter = new StringRegistry.StringWriter();
                stringWriter.startChange();
                try {
                    List<LocalStyleHolder> list = ModuleInfoUtil.collectLocalStyle(moduleInfo, flexLibrarySet.getVersion(), stringWriter, problemsHolder, projectComponentReferenceCounter, flexLibrarySet.assetCounterInfo.demanded);
                    // todo we shouldn't create list, we should check while collecting
                    boolean hasChanges = true;
                    if (list.size() == oldList.size()) {
                        int diff = list.size();
                        for (LocalStyleHolder holder : list) {
                            if (oldList.contains(holder)) {
                                diff--;
                            }
                        }
                        hasChanges = diff != 0;
                    }
                    if (hasChanges) {
                        moduleInfo.setLocalStyleHolders(list);
                        client.fillAssetClassPoolIfNeed(flexLibrarySet);
                        client.updateLocalStyleHolders(localStyleSources, stringWriter);
                        if (projectComponentReferenceCounter.hasUnregistered()) {
                            client.registerDocumentReferences(projectComponentReferenceCounter.unregistered, null, problemsHolder);
                        }
                    } else {
                        stringWriter.rollback();
                        localStyleSources.remove(moduleInfo);
                    }
                } catch (Throwable e) {
                    stringWriter.rollback();
                    LOG.error(e);
                }
            } catch (Throwable e) {
                LOG.error(e);
            }
            return true;
        }
    });
    if (!problemsHolder.isEmpty() && reportProblems) {
        DocumentProblemManager.getInstance().report(null, problemsHolder);
    }
}
Also used : ProjectComponentReferenceCounter(com.intellij.flex.uiDesigner.mxml.ProjectComponentReferenceCounter) StringRegistry(com.intellij.flex.uiDesigner.io.StringRegistry) FlexLibrarySet(com.intellij.flex.uiDesigner.libraries.FlexLibrarySet) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

StringRegistry (com.intellij.flex.uiDesigner.io.StringRegistry)1 FlexLibrarySet (com.intellij.flex.uiDesigner.libraries.FlexLibrarySet)1 ProjectComponentReferenceCounter (com.intellij.flex.uiDesigner.mxml.ProjectComponentReferenceCounter)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1