コード例 #1
0
ファイル: FolderInfoModification.java プロジェクト: zhaog/cdt
  private void applyToolChain(ToolChain newNonRealTc) {
    ToolChain newRealTc = (ToolChain) ManagedBuildManager.getRealToolChain(newNonRealTc);

    ToolChainApplicabilityPaths tcApplicability = getToolChainApplicabilityPaths();
    PerTypeMapStorage<? extends IRealBuildObjectAssociation, Set<IPath>> storage =
        getCompleteObjectStore();

    @SuppressWarnings("unchecked")
    Map<ToolChain, Set<IPath>> tcMap =
        (Map<ToolChain, Set<IPath>>)
            storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOLCHAIN, false);
    @SuppressWarnings("unchecked")
    Map<Tool, Set<IPath>> toolMap =
        (Map<Tool, Set<IPath>>) storage.getMap(IRealBuildObjectAssociation.OBJECT_TOOL, false);

    TcModificationUtil.removePaths(tcMap, fRealToolChain, tcApplicability.fFolderInfoPaths);
    TcModificationUtil.addPaths(tcMap, newRealTc, tcApplicability.fFolderInfoPaths);
    Tool[] newTools = (Tool[]) newNonRealTc.getTools();

    for (int i = 0; i < newTools.length; i++) {
      newTools[i] = (Tool) ManagedBuildManager.getRealTool(newTools[i]);
    }

    Set<Entry<Tool, Set<IPath>>> entrySet = tcApplicability.fToolPathMap.entrySet();
    for (Iterator<Entry<Tool, Set<IPath>>> iter = entrySet.iterator(); iter.hasNext(); ) {
      Map.Entry<Tool, Set<IPath>> entry = iter.next();
      Tool tool = entry.getKey();
      Set<IPath> pathSet = entry.getValue();

      TcModificationUtil.removePaths(toolMap, tool, pathSet);
    }

    for (int i = 0; i < newTools.length; i++) {
      TcModificationUtil.addPaths(toolMap, newTools[i], tcApplicability.fFolderInfoPaths);
    }

    if (tcApplicability.fFileInfoPaths.size() != 0) {
      FolderInfo foInfo = (FolderInfo) getResourceInfo();
      IManagedProject mProj = foInfo.getParent().getManagedProject();
      IProject project = mProj.getOwner().getProject();
      Tool[] filtered = (Tool[]) foInfo.filterTools(newTools, mProj);
      if (filtered.length != 0) {
        for (IPath p : tcApplicability.fFileInfoPaths) {
          boolean found = false;
          String ext = p.getFileExtension();
          if (ext == null) ext = ""; // $NON-NLS-1$
          for (int i = 0; i < filtered.length; i++) {
            if (filtered[i].buildsFileType(ext, project)) {
              TcModificationUtil.addPath(toolMap, filtered[i], p);
              found = true;
              break;
            }
          }

          if (!found) {
            if (DbgTcmUtil.DEBUG) {
              DbgTcmUtil.println("no tools found for path " + p); // $NON-NLS-1$
            }
          }
        }

      } else if (DbgTcmUtil.DEBUG) {
        DbgTcmUtil.println("no filtered tools"); // $NON-NLS-1$
      }
    }
  }