private void registerControlFlow(@NotNull PsiElement element, @NotNull ControlFlow flow, boolean evaluateConstantIfCondition, boolean enableShortCircuit, @NotNull ControlFlowPolicy policy) { final long modificationCount = element.getManager().getModificationTracker().getModificationCount(); ControlFlowContext controlFlowContext = createContext(evaluateConstantIfCondition, enableShortCircuit, policy, flow, modificationCount); ConcurrentList<ControlFlowContext> cached = getOrCreateCachedFlowsForElement(element); cached.addIfAbsent(controlFlowContext); }
@NotNull private ConcurrentList<ControlFlowContext> getOrCreateCachedFlowsForElement(@NotNull PsiElement element) { ConcurrentList<ControlFlowContext> cached = cachedFlows.get(element); if (cached == null) { cached = ContainerUtil.createConcurrentList(); cachedFlows.put(element, cached); } return cached; }
@NotNull public static ConcurrentList<DocumentWindow> getCachedInjectedDocuments(@NotNull PsiFile hostPsiFile) { // modification of cachedInjectedDocuments must be under PsiLock only ConcurrentList<DocumentWindow> injected = hostPsiFile.getUserData(INJECTED_DOCS_KEY); if (injected == null) { injected = ((UserDataHolderEx)hostPsiFile).putUserDataIfAbsent(INJECTED_DOCS_KEY, ContainerUtil.<DocumentWindow>createConcurrentList()); } return injected; }
/** * @deprecated use {@link InjectedLanguageManager#getCachedInjectedDocumentsInRange(PsiFile, TextRange)} instead */ @Nonnull @Deprecated public static ConcurrentList<DocumentWindow> getCachedInjectedDocuments(@Nonnull PsiFile hostPsiFile) { // modification of cachedInjectedDocuments must be under InjectedLanguageManagerImpl.ourInjectionPsiLock only ConcurrentList<DocumentWindow> injected = hostPsiFile.getUserData(INJECTED_DOCS_KEY); if (injected == null) { injected = ((UserDataHolderEx)hostPsiFile).putUserDataIfAbsent(INJECTED_DOCS_KEY, ContainerUtil.createConcurrentList()); } return injected; }
@NotNull private ConcurrentList<ControlFlowContext> getOrCreateCachedFlowsForElement(@NotNull PsiElement element) { ConcurrentList<ControlFlowContext> cached = cachedFlows.get(element); if(cached == null) { cached = ContainerUtil.createConcurrentList(); cachedFlows.put(element, cached); } return cached; }