com.intellij.lang.injection.MultiHostInjector Java Examples
The following examples show how to use
com.intellij.lang.injection.MultiHostInjector.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InjectedLanguageManagerImpl.java From consulo with Apache License 2.0 | 7 votes |
@TestOnly public static void checkInjectorsAreDisposed(@Nullable Project project) { InjectedLanguageManagerImpl cachedManager = project == null ? null : (InjectedLanguageManagerImpl)project.getUserData(INSTANCE_CACHE); if (cachedManager == null) return; try { ClassMapCachingNulls<MultiHostInjector> cached = cachedManager.cachedInjectors; if (cached == null) return; for (Map.Entry<Class<?>, MultiHostInjector[]> entry : cached.getBackingMap().entrySet()) { Class<?> key = entry.getKey(); if (cachedManager.myInjectorsClone.isEmpty()) return; MultiHostInjector[] oldInjectors = cachedManager.myInjectorsClone.get(key); for (MultiHostInjector injector : entry.getValue()) { if (ArrayUtil.indexOf(oldInjectors, injector) == -1) { throw new AssertionError("Injector was not disposed: " + key + " -> " + injector); } } } } finally { cachedManager.myInjectorsClone.clear(); } }
Example #2
Source File: InjectedLanguageManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
@Nonnull private ClassMapCachingNulls<MultiHostInjector> calcInjectorMap() { Map<Class<?>, MultiHostInjector[]> injectors = new HashMap<>(); MultiMap<Class<? extends PsiElement>, MultiHostInjector> allInjectors = new MultiMap<>(); for (MultiHostInjectorExtensionPoint extensionPoint : MultiHostInjector.EP_NAME.getExtensionList(myProject)) { allInjectors.putValue(extensionPoint.getKey(), extensionPoint.getInstance(myProject)); } if (LanguageInjector.EXTENSION_POINT_NAME.hasAnyExtensions()) { allInjectors.putValue(PsiLanguageInjectionHost.class, PsiManagerRegisteredInjectorsAdapter.INSTANCE); } for (Map.Entry<Class<? extends PsiElement>, Collection<MultiHostInjector>> injector : allInjectors.entrySet()) { Class<? extends PsiElement> place = injector.getKey(); Collection<MultiHostInjector> value = injector.getValue(); injectors.put(place, value.toArray(new MultiHostInjector[0])); } return new ClassMapCachingNulls<>(injectors, new MultiHostInjector[0], new ArrayList<>(allInjectors.values())); }
Example #3
Source File: InjectedLanguageManagerImpl.java From consulo with Apache License 2.0 | 6 votes |
InjectionResult processInPlaceInjectorsFor(@Nonnull PsiFile hostPsiFile, @Nonnull PsiElement element) { MultiHostInjector[] infos = getInjectorMap().get(element.getClass()); if (infos == null || infos.length == 0) { return null; } final boolean dumb = myDumbService.isDumb(); InjectionRegistrarImpl hostRegistrar = new InjectionRegistrarImpl(myProject, hostPsiFile, element, myDocManager); for (MultiHostInjector injector : infos) { if (dumb && !DumbService.isDumbAware(injector)) { continue; } injector.injectLanguages(hostRegistrar, element); InjectionResult result = hostRegistrar.getInjectedResult(); if (result != null) return result; } return null; }
Example #4
Source File: MultiHostInjectorExtensionPoint.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull public MultiHostInjector getInstance(@Nonnull ComponentManager componentManager) { if(myInstance == null) { myInstance = instantiate(myImplementationClassHandler.getValue(), componentManager.getInjectingContainer()); } return myInstance; }
Example #5
Source File: InjectedLanguageManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public void processInjectableElements(@Nonnull Collection<? extends PsiElement> in, @Nonnull Processor<? super PsiElement> processor) { ClassMapCachingNulls<MultiHostInjector> map = getInjectorMap(); for (PsiElement element : in) { if (map.get(element.getClass()) != null) { processor.process(element); } } }
Example #6
Source File: InjectedLanguageManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private ClassMapCachingNulls<MultiHostInjector> getInjectorMap() { ClassMapCachingNulls<MultiHostInjector> cached = cachedInjectors; if (cached != null) { return cached; } ClassMapCachingNulls<MultiHostInjector> result = calcInjectorMap(); cachedInjectors = result; return result; }