@memoized_property
  def targets_by_file(self):
    targets_by_file = defaultdict(OrderedSet)
    runtime_classpath = self.context.products.get_data('runtime_classpath')

    # Compute src -> target.
    self.context.log.debug('Mapping sources...')
    buildroot = get_buildroot()
    # Look at all targets in-play for this pants run. Does not include synthetic targets,
    for target in self.context.targets():
      if isinstance(target, JvmTarget):
        for src in target.sources_relative_to_buildroot():
          targets_by_file[os.path.join(buildroot, src)].add(target)
      # TODO(Tejal Desai): pantsbuild/pants/65: Remove java_sources attribute for ScalaLibrary
      if isinstance(target, ScalaLibrary):
        for java_source in target.java_sources:
          for src in java_source.sources_relative_to_buildroot():
            targets_by_file[os.path.join(buildroot, src)].add(target)

    # Compute classfile -> target and jar -> target.
    self.context.log.debug('Mapping classpath...')
    for target in self.context.targets():
      # Classpath content.
      files = ClasspathUtil.classpath_contents((target,), runtime_classpath)
      # And jars; for binary deps, zinc doesn't emit precise deps (yet).
      cp_entries = ClasspathUtil.classpath((target,), runtime_classpath)
      jars = [cpe for cpe in cp_entries if ClasspathUtil.is_jar(cpe)]
      for coll in [files, jars]:
        for f in coll:
          targets_by_file[f].add(target)

    return targets_by_file
Returns a map from abs path of source, class or jar file to an OrderedSet of targets.
dataset/ETHPy150Open pantsbuild/pants/src/python/pants/backend/jvm/tasks/jvm_dependency_analyzer.py/JvmDependencyAnalyzer.targets_by_file