@Override public void registerMultiHostInjector(@NotNull MultiHostInjector injector) { for (Class<? extends PsiElement> place : injector.elementsToInjectIn()) { LOG.assertTrue(place != null, injector); while (true) { MultiHostInjector[] injectors = this.injectors.get(place); if (injectors == null) { if (this.injectors.putIfAbsent(place, new MultiHostInjector[] {injector}) == null) break; } else { MultiHostInjector[] newInfos = ArrayUtil.append(injectors, injector); if (this.injectors.replace(place, injectors, newInfos)) break; } } } cachedInjectors.clearCache(); }
@Override public boolean unregisterMultiHostInjector(@NotNull MultiHostInjector injector) { boolean removed = false; Iterator<Map.Entry<Class, MultiHostInjector[]>> iterator = injectors.entrySet().iterator(); while (iterator.hasNext()) { Map.Entry<Class, MultiHostInjector[]> entry = iterator.next(); MultiHostInjector[] infos = entry.getValue(); int i = ArrayUtil.find(infos, injector); if (i != -1) { MultiHostInjector[] newInfos = ArrayUtil.remove(infos, i); if (newInfos.length == 0) { iterator.remove(); } else { injectors.put(entry.getKey(), newInfos); } removed = true; } } cachedInjectors.clearCache(); return removed; }