package jetbrains.mps.kotlin.idePlugin.fastSearch;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import com.intellij.psi.impl.cache.impl.id.IdIndexer;
import org.jetbrains.annotations.NotNull;
import java.util.Map;
import com.intellij.psi.impl.cache.impl.id.IdIndexEntry;
import com.intellij.util.indexing.FileContent;
import kotlinx.metadata.internal.common.KotlinCommonMetadata;

/**
 * Indexes the content of kotlin metadata files (declared in plugin.xml of mps kotlin).
 * 
 * @see jetbrains.mps.kotlin.idePlugin.fileTypes.KotlinMetadataFileType 
 */
@GeneratedClass(node = "r:839db98b-6aa7-4fd6-a3a0-c413dbdb3e27(jetbrains.mps.kotlin.idePlugin.fastSearch)/8550542210337515460", model = "r:839db98b-6aa7-4fd6-a3a0-c413dbdb3e27(jetbrains.mps.kotlin.idePlugin.fastSearch)")
public class KotlinStubIdIndexer implements IdIndexer {
  @NotNull
  @Override
  public Map<IdIndexEntry, Integer> map(@NotNull FileContent content) {
    // Parse (registry with extensions allows to get annotations)
    KotlinCommonMetadata metadata = KotlinCommonMetadata.read(content.getContent());
    KtModuleIndexer indexer = new KtModuleIndexer();
    if (metadata != null) {
      // Visit content and collect indexes
      indexer.indexModule(metadata.toKmModuleFragment());
    }
    return indexer.getEntries();
  }
}
