package jetbrains.mps.java.core.sourceStubs;

/*Generated by MPS */

import jetbrains.mps.annotations.GeneratedClass;
import org.jetbrains.mps.openapi.persistence.FindUsagesParticipant;
import com.intellij.openapi.Disposable;
import org.jetbrains.mps.openapi.persistence.PersistenceFacade;
import java.util.Collection;
import org.jetbrains.mps.openapi.model.SModel;
import java.util.Set;
import org.jetbrains.mps.openapi.model.SNode;
import org.jetbrains.mps.openapi.util.Consumer;
import org.jetbrains.mps.openapi.model.SReference;
import org.jetbrains.mps.openapi.language.SAbstractConcept;
import org.jetbrains.mps.openapi.model.SModelReference;

/**
 * Will be gone when I implement find usages for source stubs.
 * For now MPS seems to do the default thing: goes through the model nodes which turns out to be very slow
 */
@GeneratedClass(node = "r:39747a8f-4d04-48b7-83c5-4b4f5e43330c(jetbrains.mps.java.core.sourceStubs)/9207707776056494296", model = "r:39747a8f-4d04-48b7-83c5-4b4f5e43330c(jetbrains.mps.java.core.sourceStubs)")
public class EmptyJavaSourceStubsFindUsages implements FindUsagesParticipant, Disposable {

  public EmptyJavaSourceStubsFindUsages() {
    PersistenceFacade.getInstance().addFindUsagesParticipant(this);
  }

  public void findUsages(Collection<SModel> models, Set<SNode> set, Consumer<SReference> consumer, Consumer<SModel> processedConsumer) {
    // just skipping java psi stub models from find usages
    // usages in java should be found via idea ReferenceSearch
    for (SModel model : models) {
      if (model instanceof JavaSourceStubModelDescriptor) {
        processedConsumer.consume(model);
      }
    }
  }

  public void findInstances(Collection<SModel> collection, Set<SAbstractConcept> set, Consumer<SNode> consumer, Consumer<SModel> consumer1) {
    // let's not skip this, it's not going to slow down anything
  }

  public void findModelUsages(Collection<SModel> collection, Set<SModelReference> set, Consumer<SModel> consumer, Consumer<SModel> consumer1) {
    // let's not skip this, it's not going to slow down anything
  }

  @Override
  public void dispose() {
    PersistenceFacade.getInstance().removeFindUsagesParticipant(this);
  }
}
