<commit_before>package io.michaelrocks.grip

import io.michaelrocks.grip.mirrors.AnnotationMirror
import io.michaelrocks.grip.mirrors.ClassMirror
import io.michaelrocks.grip.mirrors.Reflector
import io.michaelrocks.grip.mirrors.buildAnnotation
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import java.io.File
import java.util.*

interface ClassRegistry {
  fun classpath(): Collection<File>
  fun findTypesForFile(file: File): Collection<Type>
  fun getClassMirror(type: Type): ClassMirror
  fun getAnnotationMirror(type: Type): AnnotationMirror
}

internal class ClassRegistryImpl(
    private val fileRegistry: FileRegistry,
    private val reflector: Reflector
) : ClassRegistry {
  private val classesByType = HashMap<Type, ClassMirror>()
  private val annotationsByType = HashMap<Type, AnnotationMirror>()

  override fun classpath(): Collection<File> =
      fileRegistry.classpath()

  override fun findTypesForFile(file: File): Collection<Type> =
      fileRegistry.findTypesForFile(file)

  override fun getClassMirror(type: Type): ClassMirror =
      classesByType.getOrPut(type) { readClassMirror(type, false) }

  override fun getAnnotationMirror(type: Type): AnnotationMirror =
      annotationsByType.getOrPut(type) {
        val classMirror = classesByType[type] ?: classesByType[type] ?: readClassMirror(type, true)
        buildAnnotation(type) {
          check(classMirror.access or Opcodes.ACC_ANNOTATION != 0)
          for (method in classMirror.methods) {
            method.defaultValue?.let { addValue(method.name, it) }
          }
        }<commit_msg>Remove methods delegated to FileRegistry from ClassRegistry<commit_after>package io.michaelrocks.grip

import io.michaelrocks.grip.mirrors.AnnotationMirror
import io.michaelrocks.grip.mirrors.ClassMirror
import io.michaelrocks.grip.mirrors.Reflector
import io.michaelrocks.grip.mirrors.buildAnnotation
import org.objectweb.asm.Opcodes
import org.objectweb.asm.Type
import java.util.*

interface ClassRegistry {
  fun getClassMirror(type: Type): ClassMirror
  fun getAnnotationMirror(type: Type): AnnotationMirror
}

internal class ClassRegistryImpl(
    private val fileRegistry: FileRegistry,
    private val reflector: Reflector
) : ClassRegistry {
  private val classesByType = HashMap<Type, ClassMirror>()
  private val annotationsByType = HashMap<Type, AnnotationMirror>()

  override fun getClassMirror(type: Type): ClassMirror =
      classesByType.getOrPut(type) { readClassMirror(type, false) }

  override fun getAnnotationMirror(type: Type): AnnotationMirror =
      annotationsByType.getOrPut(type) {
        val classMirror = classesByType[type] ?: classesByType[type] ?: readClassMirror(type, true)
        buildAnnotation(type) {
          check(classMirror.access or Opcodes.ACC_ANNOTATION != 0)
          for (method in classMirror.methods) {
            method.defaultValue?.let { addValue(method.name, it) }
          }
        }
{'fraction_non_alphanumeric': 0.09032258064516129, 'fraction_numerical': 0.0006791171477079797, 'mean_word_length': 4.548022598870056, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6438521', 'n_tokens_mistral': 891, 'n_tokens_neox': 847, 'n_words': 186}