void (String @NotNull [] names, PsiNamePatternCondition<?> nameCondition, @NotNull Class<?> scopeClass, boolean caseSensitive, @NotNull PsiReferenceProvider provider, double priority, @NotNull ElementPattern<?> pattern, @Nullable Disposable parentDisposable) { NamedObjectProviderBinding providerBinding = myNamedBindingsMap.get(scopeClass); if (providerBinding == null) { myNamedBindingsMap.put(scopeClass, providerBinding = new NamedObjectProviderBinding() { @Override protected String getName(@NotNull PsiElement position) { return nameCondition.getPropertyValue(position); } }); } providerBinding.registerProvider(names, pattern, caseSensitive, provider, priority); if (parentDisposable != null) { NamedObjectProviderBinding finalProviderBinding = providerBinding; Disposable disposable = new Disposable() { @Override public void dispose() { finalProviderBinding.unregisterProvider(provider); if (finalProviderBinding.isEmpty()) { myNamedBindingsMap.remove(scopeClass); } myCleanupDisposables.remove(this); } }; myCleanupDisposables.add(disposable); Disposer.register(parentDisposable, disposable); } }