Search in sources :

Example 1 with FlexStyleIndexInfo

use of com.intellij.javascript.flex.css.FlexStyleIndexInfo in project intellij-plugins by JetBrains.

the class LibraryStyleInfoCollector method collectInherited.

private byte[] collectInherited(final VirtualFile jarFile) {
    bytes.allocateShort();
    final VirtualFile libraryFile = Library.getSwfFile(jarFile);
    final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
    final GlobalSearchScope searchScope = GlobalSearchScope.fileScope(module.getProject(), libraryFile);
    final List<String> dataKeys = new ArrayList<>(32);
    fileBasedIndex.processAllKeys(FlexStyleIndex.INDEX_ID, dataKey -> {
        dataKeys.add(dataKey);
        return true;
    }, module.getProject());
    final THashSet<String> uniqueGuard = new THashSet<>();
    final FileBasedIndex.ValueProcessor<Set<FlexStyleIndexInfo>> processor = (file, value) -> {
        final FlexStyleIndexInfo firstInfo = value.iterator().next();
        if (firstInfo.getInherit().charAt(0) == 'y' && uniqueGuard.add(firstInfo.getAttributeName())) {
            bytes.writeUInt29(stringWriter.getReference(firstInfo.getAttributeName()) - 1);
        }
        // may not be in a class stylePName be inherited, and another class of the same library not inherited
        return false;
    };
    for (String dataKey : dataKeys) {
        fileBasedIndex.processValues(FlexStyleIndex.INDEX_ID, dataKey, libraryFile, processor, searchScope);
    }
    if (uniqueGuard.isEmpty()) {
        return null;
    } else {
        bytes.putShort(uniqueGuard.size(), 0);
        return bytes.getByteArrayOut().toByteArray();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) ByteArrayOutputStreamEx(com.intellij.flex.uiDesigner.io.ByteArrayOutputStreamEx) StringWriter(com.intellij.flex.uiDesigner.io.StringRegistry.StringWriter) FlexStyleIndex(com.intellij.javascript.flex.css.FlexStyleIndex) AssetCounter(com.intellij.flex.uiDesigner.AssetCounter) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PrimitiveAmfOutputStream(com.intellij.flex.uiDesigner.io.PrimitiveAmfOutputStream) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) Set(java.util.Set) THashSet(gnu.trove.THashSet) ArrayList(java.util.ArrayList) List(java.util.List) CssWriter(com.intellij.flex.uiDesigner.css.CssWriter) ProblemsHolder(com.intellij.flex.uiDesigner.ProblemsHolder) FlexStyleIndexInfo(com.intellij.javascript.flex.css.FlexStyleIndexInfo) Module(com.intellij.openapi.module.Module) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) Set(java.util.Set) THashSet(gnu.trove.THashSet) GlobalSearchScope(com.intellij.psi.search.GlobalSearchScope) ArrayList(java.util.ArrayList) FlexStyleIndexInfo(com.intellij.javascript.flex.css.FlexStyleIndexInfo) FileBasedIndex(com.intellij.util.indexing.FileBasedIndex) THashSet(gnu.trove.THashSet)

Aggregations

AssetCounter (com.intellij.flex.uiDesigner.AssetCounter)1 ProblemsHolder (com.intellij.flex.uiDesigner.ProblemsHolder)1 CssWriter (com.intellij.flex.uiDesigner.css.CssWriter)1 ByteArrayOutputStreamEx (com.intellij.flex.uiDesigner.io.ByteArrayOutputStreamEx)1 PrimitiveAmfOutputStream (com.intellij.flex.uiDesigner.io.PrimitiveAmfOutputStream)1 StringWriter (com.intellij.flex.uiDesigner.io.StringRegistry.StringWriter)1 FlexStyleIndex (com.intellij.javascript.flex.css.FlexStyleIndex)1 FlexStyleIndexInfo (com.intellij.javascript.flex.css.FlexStyleIndexInfo)1 Module (com.intellij.openapi.module.Module)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)1 FileBasedIndex (com.intellij.util.indexing.FileBasedIndex)1 THashSet (gnu.trove.THashSet)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Set (java.util.Set)1