private IFile fileForContent(String name, boolean isCache) {
    // RE-3090
    // RE-3635
    if (name.endsWith(TraceInfoCache.TRACE_FILE_NAME)) {
      // RE-3103
      if (myOriginalOutputDir instanceof IdeaFile) {
        IdeaFile originalOutputDirIdeaFile = (IdeaFile) myOriginalOutputDir;
        if (!originalOutputDirIdeaFile.isPackaged()) {
          return FileGenerationUtil.getDefaultOutputDir(myModelDescriptor, myOriginalOutputDir)
              .getDescendant(name);
        }
      }
    }

    IFile outputRootDir = isCache ? myCachesOutputDir : myOutputDir;

    CodeOrchestraGenerateManager codeOrchestraGenerateManager =
        myProcessor.getProject().getComponent(CodeOrchestraGenerateManager.class);
    CodeOrchestraGenerationContext currentContext =
        codeOrchestraGenerateManager.getCurrentContext();
    if (currentContext != null) {
      String fqName =
          NameUtil.longNameFromNamespaceAndShortName(
              myModelDescriptor.getLongName(), getRootNameFromFileName(name));
      if (fqName != null) {
        FileOverrideWrapper customMapping = currentContext.getCustomFileFqNameMapping(fqName);
        if (customMapping != null) {
          return FileGenerationUtil.getDefaultOutputDir(
                  NameUtil.namespaceFromLongName(customMapping.getTargetFqName()), outputRootDir)
              .getDescendant(
                  NameUtil.shortNameFromLongName(customMapping.getTargetFqName())
                      + customMapping.getExtension());
        }
      }
    }

    return FileGenerationUtil.getDefaultOutputDir(myModelDescriptor, outputRootDir)
        .getDescendant(name);
  }