class ProjectClassesInstanceFilter implements CaptureObjectInstanceFilter {

  @Override
  public Set<InstanceObject> filter(@NotNull Set<InstanceObject> instances, @NotNull ClassDb classDatabase) {
    Set<String> projectClasses = myIdeProfilerServices.getAllProjectClasses();
    return instances.stream().filter(instance -> {
      String className = instance.getClassEntry().getClassName();

      // Ignore inner classes since they can contain lambdas (e.g. topLevelClass$1). All inner classes should be included anyway if
      // the top-level class belongs to the project.
      int innerClassStartIndex = className.indexOf("$");
      if (innerClassStartIndex != -1) {
        className = className.substring(0, innerClassStartIndex);
      }

      return projectClasses.contains(className);
    }).collect(Collectors.toSet());
  }

  public  ProjectClassesInstanceFilter(@NotNull IdeProfilerServices profilerServices);

}