com.intellij.psi.util.ParameterizedCachedValue Java Examples
The following examples show how to use
com.intellij.psi.util.ParameterizedCachedValue.
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: PsiCachedValuesFactory.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public <T, P> ParameterizedCachedValue<T, P> createParameterizedCachedValue(@Nonnull ParameterizedCachedValueProvider<T, P> provider, boolean trackValue) { return new PsiParameterizedCachedValue<>(myManager, provider, trackValue); }
Example #2
Source File: ConcatenationInjectorManager.java From consulo with Apache License 2.0 | 4 votes |
@Override public void injectLanguages(@Nonnull MultiHostRegistrar registrar, @Nonnull PsiElement context) { ConcatenationInjectorManager manager = getInstance(myProject); if (manager.myConcatenationInjectors.isEmpty()) { return; } final PsiFile containingFile = ((InjectionRegistrarImpl)registrar).getHostPsiFile(); Project project = containingFile.getProject(); long modificationCount = PsiManager.getInstance(project).getModificationTracker().getModificationCount(); Pair<PsiElement, PsiElement[]> pair = computeAnchorAndOperands(context); PsiElement anchor = pair.first; PsiElement[] operands = pair.second; Integer noInjectionTimestamp = anchor.getUserData(NO_CONCAT_INJECTION_TIMESTAMP); InjectionResult result; ParameterizedCachedValue<InjectionResult, PsiElement> data = null; if (operands.length == 0 || noInjectionTimestamp != null && noInjectionTimestamp == modificationCount) { result = null; } else { data = anchor.getUserData(INJECTED_PSI_IN_CONCATENATION); result = data == null ? null : data.getValue(context); if (result == null || !result.isValid()) { result = doCompute(containingFile, project, anchor, operands); } } if (result != null) { ((InjectionRegistrarImpl)registrar).addToResults(result); if (data == null) { CachedValueProvider.Result<InjectionResult> cachedResult = CachedValueProvider.Result.create(result, manager); data = CachedValuesManager.getManager(project).createParameterizedCachedValue(context1 -> { PsiFile containingFile1 = context1.getContainingFile(); Project project1 = containingFile1.getProject(); Pair<PsiElement, PsiElement[]> pair1 = computeAnchorAndOperands(context1); InjectionResult result1 = pair1.second.length == 0 ? null : doCompute(containingFile1, project1, pair1.first, pair1.second); return result1 == null ? null : CachedValueProvider.Result.create(result1, manager); }, false); ((PsiParameterizedCachedValue<InjectionResult, PsiElement>)data).setValue(cachedResult); anchor.putUserData(INJECTED_PSI_IN_CONCATENATION, data); if (anchor.getUserData(NO_CONCAT_INJECTION_TIMESTAMP) != null) { anchor.putUserData(NO_CONCAT_INJECTION_TIMESTAMP, null); } } } else { // cache no-injection flag if (anchor.getUserData(INJECTED_PSI_IN_CONCATENATION) != null) { anchor.putUserData(INJECTED_PSI_IN_CONCATENATION, null); } anchor.putUserData(NO_CONCAT_INJECTION_TIMESTAMP, (int)modificationCount); } }
Example #3
Source File: CachedValuesFactory.java From consulo with Apache License 2.0 | votes |
<T, P> ParameterizedCachedValue<T, P> createParameterizedCachedValue(@Nonnull ParameterizedCachedValueProvider<T, P> provider, boolean trackValue);