本文整理汇总了Java中com.intellij.psi.util.CachedValue类的典型用法代码示例。如果您正苦于以下问题:Java CachedValue类的具体用法?Java CachedValue怎么用?Java CachedValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CachedValue类属于com.intellij.psi.util包,在下文中一共展示了CachedValue类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypeSystemMeta
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
@Override
public synchronized TSMetaModel getTypeSystemMeta(@Nullable final PsiFile contextFile) {
if (contextFile == null || !TSMetaModelBuilder.isTsFile(contextFile)) {
return myCachedValue.getValue();
}
final TSMetaModelImpl externalModel = doGetExternalModel(contextFile);
final Project project = contextFile.getProject();
CachedValue<TSMetaModelImpl> fileModelCache = contextFile.getUserData(FILE_MODEL_CACHE_KEY);
if (fileModelCache == null) {
fileModelCache = CachedValuesManager.getManager(project).createCachedValue(
() -> ApplicationManager.getApplication().runReadAction(
(Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {
final TSMetaModelBuilder builder = new TSMetaModelBuilder(project);
final TSMetaModelImpl modelForFile = builder.buildModelForFile(contextFile);
return CachedValueProvider.Result.create(modelForFile, contextFile);
}), false);
contextFile.putUserData(FILE_MODEL_CACHE_KEY, fileModelCache);
}
final TSMetaModelImpl fileModel = fileModelCache.getValue();
return new TSMetaModelImpl(Arrays.asList(externalModel, fileModel));
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:25,代码来源:TSMetaModelAccessImpl.java
示例2: doGetExternalModel
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
@NotNull
private TSMetaModelImpl doGetExternalModel(final @NotNull PsiFile contextFile) {
final PsiFile originalFile = contextFile.getOriginalFile();
final VirtualFile vFile = originalFile.getVirtualFile();
final Project project = originalFile.getProject();
CachedValue<TSMetaModelImpl> externalModelCache = originalFile.getUserData(EXTERNAL_MODEL_CACHE_KEY);
if (externalModelCache == null) {
externalModelCache = CachedValuesManager.getManager(project).createCachedValue(
() -> ApplicationManager.getApplication().runReadAction(
(Computable<CachedValueProvider.Result<TSMetaModelImpl>>) () -> {
final List<VirtualFile> excludes = vFile == null
? Collections.emptyList()
: Collections.singletonList(vFile);
final TSMetaModelBuilder builder = new TSMetaModelBuilder(project, excludes);
final TSMetaModelImpl model = builder.buildModel();
return CachedValueProvider.Result.create(model, builder.getFiles());
}), false);
originalFile.putUserData(EXTERNAL_MODEL_CACHE_KEY, externalModelCache);
}
return externalModelCache.getValue();
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:27,代码来源:TSMetaModelAccessImpl.java
示例3: JavaConstantExpressionEvaluator
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
private JavaConstantExpressionEvaluator(Set<PsiVariable> visitedVars,
final boolean throwExceptionOnOverflow,
@NotNull Project project,
final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
myMapFactory = auxEvaluator == null ? new Factory<ConcurrentMap<PsiElement, Object>>() {
@Override
public ConcurrentMap<PsiElement, Object> create() {
final Key<CachedValue<ConcurrentMap<PsiElement, Object>>> key =
throwExceptionOnOverflow ? CONSTANT_VALUE_WITH_OVERFLOW_MAP_KEY : CONSTANT_VALUE_WO_OVERFLOW_MAP_KEY;
return CachedValuesManager.getManager(myProject).getCachedValue(myProject, key, PROVIDER, false);
}
} : new Factory<ConcurrentMap<PsiElement, Object>>() {
@Override
public ConcurrentMap<PsiElement, Object> create() {
return auxEvaluator.getCacheMap(throwExceptionOnOverflow);
}
};
myProject = project;
myConstantExpressionVisitor = new ConstantExpressionVisitor(visitedVars, throwExceptionOnOverflow, auxEvaluator);
}
示例4: getFileToArtifactsMap
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
public CachedValue<MultiValuesMap<VirtualFile, Artifact>> getFileToArtifactsMap() {
if (myFile2Artifacts == null) {
myFile2Artifacts =
CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<MultiValuesMap<VirtualFile, Artifact>>() {
public Result<MultiValuesMap<VirtualFile, Artifact>> compute() {
MultiValuesMap<VirtualFile, Artifact> result = computeFileToArtifactsMap();
List<ModificationTracker> trackers = new ArrayList<ModificationTracker>();
trackers.add(ArtifactManager.getInstance(myProject).getModificationTracker());
for (ComplexPackagingElementType<?> type : PackagingElementFactory.getInstance().getComplexElementTypes()) {
ContainerUtil.addIfNotNull(type.getAllSubstitutionsModificationTracker(myProject), trackers);
}
return Result.create(result, trackers.toArray(new ModificationTracker[trackers.size()]));
}
}, false);
}
return myFile2Artifacts;
}
示例5: getRootToFacetsMap
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
private <F extends Facet & FacetRootsProvider> Map<VirtualFile, List<Facet>> getRootToFacetsMap(final FacetTypeId<F> type) {
CachedValue<Map<VirtualFile, List<Facet>>> cachedValue = myCachedMaps.get(type);
if (cachedValue == null) {
cachedValue = myCachedValuesManager.createCachedValue(new CachedValueProvider<Map<VirtualFile, List<Facet>>>() {
@Override
public Result<Map<VirtualFile, List<Facet>>> compute() {
Map<VirtualFile, List<Facet>> map = computeRootToFacetsMap(type);
return Result.create(map, getAllFacetsOfTypeModificationTracker(type));
}
}, false);
myCachedMaps.put(type, cachedValue);
}
final Map<VirtualFile, List<Facet>> value = cachedValue.getValue();
LOG.assertTrue(value != null);
return value;
}
示例6: compute
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
@Override
protected CachedValue<PsiReference[]> compute(final PsiElement element, Object p) {
return CachedValuesManager.getManager(element.getProject()).createCachedValue(new CachedValueProvider<PsiReference[]>() {
public Result<PsiReference[]> compute() {
IssueNavigationConfiguration navigationConfiguration = IssueNavigationConfiguration.getInstance(element.getProject());
if (navigationConfiguration == null) {
return Result.create(PsiReference.EMPTY_ARRAY, element);
}
List<PsiReference> refs = null;
GlobalPathReferenceProvider provider = myReferenceProvider.get();
CharSequence commentText = StringUtil.newBombedCharSequence(element.getText(), 500);
for (IssueNavigationConfiguration.LinkMatch link : navigationConfiguration.findIssueLinks(commentText)) {
if (refs == null) refs = new SmartList<PsiReference>();
if (provider == null) {
provider = (GlobalPathReferenceProvider)PathReferenceManager.getInstance().getGlobalWebPathReferenceProvider();
myReferenceProvider.lazySet(provider);
}
provider.createUrlReference(element, link.getTargetUrl(), link.getRange(), refs);
}
PsiReference[] references = refs != null ? refs.toArray(new PsiReference[refs.size()]) : PsiReference.EMPTY_ARRAY;
return new Result<PsiReference[]>(references, element, navigationConfiguration);
}
}, false);
}
示例7: _getOrCreateProblemsHolder
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
private DomElementsProblemsHolderImpl _getOrCreateProblemsHolder(final DomFileElement element) {
DomElementsProblemsHolderImpl holder;
final DomElement rootElement = element.getRootElement();
final XmlTag rootTag = rootElement.getXmlTag();
if (rootTag == null) return new DomElementsProblemsHolderImpl(element);
holder = rootTag.getUserData(DOM_PROBLEM_HOLDER_KEY);
if (isHolderOutdated(element.getFile()) || holder == null) {
holder = new DomElementsProblemsHolderImpl(element);
rootTag.putUserData(DOM_PROBLEM_HOLDER_KEY, holder);
final CachedValue<Boolean> cachedValue = CachedValuesManager.getManager(myProject).createCachedValue(new CachedValueProvider<Boolean>() {
@Override
public Result<Boolean> compute() {
return new Result<Boolean>(Boolean.FALSE, element, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, DomElementAnnotationsManagerImpl.this, ProjectRootManager.getInstance(myProject));
}
}, false);
cachedValue.getValue();
element.getFile().putUserData(CACHED_VALUE_KEY, cachedValue);
}
return holder;
}
示例8: invoke
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
@Override
public Object invoke(final DomInvocationHandler<?, ?> handler, final Object[] args) throws Throwable {
if (myConverter == Converter.EMPTY_CONVERTER) {
return getValueInner(handler, myConverter);
}
CachedValue<List<Pair<Converter,Object>>> value = handler.getUserData(DOM_VALUE_KEY);
if (value == null) {
final DomManagerImpl domManager = handler.getManager();
final Project project = domManager.getProject();
final CachedValuesManager cachedValuesManager = CachedValuesManager.getManager(project);
handler.putUserData(DOM_VALUE_KEY, value = cachedValuesManager.createCachedValue(new CachedValueProvider<List<Pair<Converter,Object>>>() {
@Override
public Result<List<Pair<Converter,Object>>> compute() {
List<Pair<Converter, Object>> list = ContainerUtil.createLockFreeCopyOnWriteList();
return Result
.create(list, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, domManager, ProjectRootManager.getInstance(project));
}
}, false));
}
return getOrCalcValue(handler, value.getValue());
}
示例9: getCachedValue
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
@Nullable
public T getCachedValue(final @NotNull H dataHolder) {
CachedValue<T> cachedValue = dataHolder.getUserData(myKey);
if (cachedValue == null) {
final CachedValueProvider<T> myProvider = new CachedValueProvider<T>() {
@Override
@Nullable
public Result<T> compute() {
return computeValue(dataHolder);
}
};
final CachedValuesManager manager = CachedValuesManager.getManager(myProject);
cachedValue = manager.createCachedValue(myProvider, false);
dataHolder.putUserData(myKey, cachedValue);
}
return cachedValue.getValue();
}
示例10: parseEntityDecl
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
private static PsiElement parseEntityDecl(final XmlEntityDecl entityDecl,
final PsiFile targetFile,
final XmlEntityDecl.EntityContextType type,
final XmlEntityRef entityRef) {
CachedValue<PsiElement> value;
synchronized (PsiLock.LOCK) { // we depend on targetFile and entityRef
value = entityRef.getUserData(PARSED_DECL_KEY);
// return entityDecl.parse(targetFile, type);
if (value == null) {
value = CachedValuesManager.getManager(entityDecl.getProject()).createCachedValue(new CachedValueProvider<PsiElement>() {
@Override
public Result<PsiElement> compute() {
final PsiElement res = entityDecl.parse(targetFile, type, entityRef);
if (res == null) return new Result<PsiElement>(res, targetFile);
if (!entityDecl.isInternalReference()) XmlEntityCache.copyEntityCaches(res.getContainingFile(), targetFile);
return new Result<PsiElement>(res, res.getUserData(XmlElement.DEPENDING_ELEMENT), entityDecl, targetFile, entityRef);
}
}, false);
entityRef.putUserData(PARSED_DECL_KEY, value);
}
}
return value.getValue();
}
示例11: createAndPutTypesCachedValue
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
private CachedValue<TypeDescriptor> createAndPutTypesCachedValue(final XmlTag tag, final Pair<QNameKey, XmlTag> pair) {
final CachedValue<TypeDescriptor> value = CachedValuesManager.getManager(tag.getProject()).createCachedValue(
new CachedValueProvider<TypeDescriptor>() {
@Override
public CachedValueProvider.Result<TypeDescriptor> compute() {
final String name = tag.getAttributeValue("name");
if (name != null &&
pair.first != null &&
pair.first.first != null &&
!name.equals(XmlUtil.findLocalNameByQualifiedName(pair.first.first))
) {
myTypesMap.remove(pair);
return new Result<TypeDescriptor>(null, PsiModificationTracker.MODIFICATION_COUNT);
}
final ComplexTypeDescriptor complexTypeDescriptor = new ComplexTypeDescriptor(XmlNSDescriptorImpl.this, tag);
return new Result<TypeDescriptor>(complexTypeDescriptor, tag);
}
}, false);
myTypesMap.put(pair, value);
return value;
}
示例12: cacheParticularEntity
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
public static void cacheParticularEntity(PsiFile file, XmlEntityDecl decl) {
synchronized(PsiLock.LOCK) {
final Map<String, CachedValue<XmlEntityDecl>> cachingMap = getCachingMap(file);
final String name = decl.getName();
if (cachingMap.containsKey(name)) return;
final SmartPsiElementPointer declPointer = SmartPointerManager.getInstance(file.getProject()).createSmartPsiElementPointer(decl);
cachingMap.put(
name, CachedValuesManager.getManager(file.getProject()).createCachedValue(new CachedValueProvider<XmlEntityDecl>() {
@Override
public Result<XmlEntityDecl> compute() {
PsiElement declElement = declPointer.getElement();
if (declElement instanceof XmlEntityDecl && declElement.isValid() && name.equals(((XmlEntityDecl)declElement).getName()))
return new Result<XmlEntityDecl>((XmlEntityDecl)declElement, declElement);
cachingMap.put(name,null);
return new Result<XmlEntityDecl>(null, ModificationTracker.NEVER_CHANGED);
}
},
false
));
}
}
示例13: getClassMap
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
@NotNull
public Map<String, PsiClass> getClassMap(@NotNull final String className, @NotNull final ClassMapConstructor constructor) {
synchronized (myClassMapLock) {
CachedValue<Map<String, PsiClass>> value = myClassMaps.get(className);
if (value == null) {
value = CachedValuesManager.getManager(getModule().getProject()).createCachedValue(
new CachedValueProvider<Map<String, PsiClass>>() {
@Nullable
@Override
public Result<Map<String, PsiClass>> compute() {
Map<String, PsiClass> map = computeClassMap(className, constructor);
return Result.create(map, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
}
}, false);
myClassMaps.put(className, value);
}
return value.getValue();
}
}
示例14: compute
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
@Nullable
@Override
public final Result<T> compute() {
AndroidFacet[] facets = myComponent.getDataBindingEnabledFacets();
List<V> values = Lists.newArrayList();
List<ModificationTracker> newDependencies = Lists.newArrayList();
newDependencies.add(myComponent);
Collections.addAll(newDependencies, myAdditionalTrackers);
for (AndroidFacet facet : facets) {
CachedValue<V> cachedValue = getCachedValue(facet);
// we know this for sure since it is created from createCacheProvider
if (cachedValue.getValueProvider() instanceof ModificationTracker) {
newDependencies.add((ModificationTracker)cachedValue.getValueProvider());
}
V result = cachedValue.getValue();
if (result != null) {
values.add(result);
}
}
myDependencyModificationCountOnCompute = calculateModificationCountFrom(newDependencies);
myDependencies = newDependencies;
return Result.create(merge(values), this);
}
示例15: createGdkMethod
import com.intellij.psi.util.CachedValue; //导入依赖的package包/类
@NotNull
public static GrGdkMethod createGdkMethod(@NotNull final PsiMethod original,
final boolean isStatic,
@Nullable final String originInfo) {
final Key<CachedValue<GrGdkMethodImpl>> cachedValueKey = isStatic ? CACHED_STATIC : CACHED_NON_STATIC;
CachedValue<GrGdkMethodImpl> cachedValue = original.getUserData(cachedValueKey);
if (cachedValue == null) {
cachedValue = CachedValuesManager.getManager(original.getProject()).createCachedValue(new CachedValueProvider<GrGdkMethodImpl>() {
@Override
public Result<GrGdkMethodImpl> compute() {
return Result.create(new GrGdkMethodImpl(original, isStatic, originInfo),
PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}
});
original.putUserData(cachedValueKey, cachedValue);
}
return cachedValue.getValue();
}