private State buildState() {
    var map = new MultiMap<SemKey<?>, BiFunction<PsiElement, ProcessingContext, Collection<? extends SemElement>>>();

    SemRegistrar registrar = new SemRegistrar() {
      @SuppressWarnings({"unchecked", "rawtypes"})
      @Override
      public <T extends SemElement> void registerSemProvider(
        SemKey<T> key,
        BiFunction<? super PsiElement, ? super ProcessingContext, ? extends Collection<T>> provider
      ) {
        map.putValue(key, (BiFunction)provider);
      }
    };

    SemContributor.EP_NAME.processWithPluginDescriptor((contributor, pluginDescriptor) -> {
      SemContributor semContributor;
      try {
        semContributor = myProject.instantiateClass(contributor.implementation, pluginDescriptor);
      }
      catch (ProcessCanceledException e) {
        throw e;
      }
      catch (ExtensionNotApplicableException e) {
        return Unit.INSTANCE;
      }
      catch (Exception e) {
        Logger.getInstance(SemServiceImpl.class).error(e);
        return Unit.INSTANCE;
      }

      if (semContributor.isAvailable(myProject)) {
        semContributor.registerSemProviders(registrar, myProject);
      }
      return Unit.INSTANCE;
    });

    Map<SemKey<?>, Collection<SemKey<?>>> inheritors = new HashMap<>();
    for (SemKey<?> key : map.keySet()) {
      putInheritors(key, key, inheritors);
    }

    return new State(map, inheritors);
  }
private State buildState()