private static void addFileDependencies(
      final BCInfo bcInfo, final VirtualFile configFile, final String workDirPath) {
    bcInfo.addFileDependency(configFile.getPath());

    try {
      final Map<String, List<String>> elementsMap =
          FlexUtils.findXMLElements(
              configFile.getInputStream(), Arrays.asList(TAGS_FOR_FILE_PATHS_IN_CONFIG_FILE));
      for (List<String> filePathList : elementsMap.values()) {
        for (String filePath : filePathList) {
          bcInfo.addFileDependency(filePath, configFile.getParent().getPath(), workDirPath);
        }
      }
    } catch (IOException e) {
      /*ignore*/
    }
  }
  public boolean isNothingChangedSincePreviousCompilation(
      final Module module, final FlexBuildConfiguration bc) {
    final Collection<BCInfo> infosForModule = myCache.get(module);
    final BCInfo existingInfo = infosForModule == null ? null : findCacheForBC(infosForModule, bc);
    if (existingInfo == null) {
      return false;
    }

    final String[] currentSourceRoots = ModuleRootManager.getInstance(module).getSourceRootUrls();
    if (!Arrays.equals(existingInfo.mySourceRootUrls, currentSourceRoots)
        || existingInfo.timestampsChanged()) {
      infosForModule.remove(existingInfo);
      if (infosForModule.isEmpty()) {
        myCache.remove(module);
      }
      return false;
    }

    return true;
  }
  public void cacheBC(
      final Module module, final FlexBuildConfiguration bc, final List<VirtualFile> configFiles) {
    Collection<BCInfo> infosForModule = myCache.get(module);
    if (infosForModule == null) {
      infosForModule = new ArrayList<BCInfo>();
      myCache.put(module, infosForModule);
    } else {
      final BCInfo existingInfo = findCacheForBC(infosForModule, bc);
      if (existingInfo != null) {
        infosForModule.remove(existingInfo);
      }
    }

    final VirtualFile outputFile =
        FlexCompilationManager.refreshAndFindFileInWriteAction(bc.getActualOutputFilePath());
    if (outputFile == null) return;

    final BCInfo bcInfo =
        new BCInfo(Factory.getCopy(bc), ModuleRootManager.getInstance(module).getSourceRootUrls());
    infosForModule.add(bcInfo);

    bcInfo.addFileDependency(outputFile.getPath());

    final String workDirPath = FlexUtils.getFlexCompilerWorkDirPath(module.getProject(), null);
    for (VirtualFile configFile : configFiles) {
      addFileDependencies(bcInfo, configFile, workDirPath);
    }

    if (bc.isTempBCForCompilation()
        && !bc.getCompilerOptions().getAdditionalConfigFilePath().isEmpty()) {
      bcInfo.addFileDependency(bc.getCompilerOptions().getAdditionalConfigFilePath());
    }

    final BuildConfigurationNature nature = bc.getNature();
    if (nature.isApp() && !nature.isWebPlatform()) {
      if (nature.isDesktopPlatform()) {
        if (!bc.getAirDesktopPackagingOptions().isUseGeneratedDescriptor()) {
          bcInfo.addFileDependency(bc.getAirDesktopPackagingOptions().getCustomDescriptorPath());
        }
      } else {
        if (bc.getAndroidPackagingOptions().isEnabled()
            && !bc.getAndroidPackagingOptions().isUseGeneratedDescriptor()) {
          bcInfo.addFileDependency(bc.getAndroidPackagingOptions().getCustomDescriptorPath());
        }
        if (bc.getIosPackagingOptions().isEnabled()
            && !bc.getIosPackagingOptions().isUseGeneratedDescriptor()) {
          bcInfo.addFileDependency(bc.getIosPackagingOptions().getCustomDescriptorPath());
        }
      }
    }
  }