本文整理汇总了Java中com.intellij.psi.util.CachedValue.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java CachedValue.getValue方法的具体用法?Java CachedValue.getValue怎么用?Java CachedValue.getValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.CachedValue
的用法示例。
在下文中一共展示了CachedValue.getValue方法的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: 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;
}
示例4: _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;
}
示例5: 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();
}
示例6: 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();
}
示例7: 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();
}
}
示例8: 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);
}
示例9: 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();
}
示例10: getIndexedBootstrapResources
import com.intellij.psi.util.CachedValue; //导入方法依赖的package包/类
@NotNull
public static Collection<ServiceResource> getIndexedBootstrapResources(@NotNull Project project) {
// cache
CachedValue<Collection<ServiceResource>> cache = project.getUserData(SERVICE_RESOURCE);
if (cache == null) {
cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(
getIndexedBootstrapResources(project, BootstrapResource.INIT_RESOURCE, BootstrapResource.AFTER_INIT_RESOURCE, BootstrapResource.AFTER_REGISTER_RESOURCE),
PsiModificationTracker.MODIFICATION_COUNT
), false);
project.putUserData(SERVICE_RESOURCE, cache);
}
return cache.getValue();
}
示例11: 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), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}
});
original.putUserData(cachedValueKey, cachedValue);
}
return cachedValue.getValue();
}
示例12: getConstructors
import com.intellij.psi.util.CachedValue; //导入方法依赖的package包/类
@NotNull
public PsiMethod[] getConstructors() {
CachedValue<PsiMethod[]> cache = myConstructorsCache;
if (cache == null) {
final CachedValuesManager manager = CachedValuesManager.getManager(myClass.getProject());
final Object[] dependencies = {PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTreeChangeTracker};
myConstructorsCache = cache = manager.createCachedValue(new CachedValueProvider<PsiMethod[]>() {
@Override
public Result<PsiMethod[]> compute() {
return Result.create(PsiImplUtil.getConstructors(myClass), dependencies);
}
}, false);
}
final PsiMethod[] constructors = cache.getValue();
return constructors != null ? constructors : PsiMethod.EMPTY_ARRAY;
}
示例13: getFields
import com.intellij.psi.util.CachedValue; //导入方法依赖的package包/类
@NotNull
public PsiField[] getFields() {
CachedValue<PsiField[]> cache = myFieldsCache;
if (cache == null) {
final CachedValuesManager manager = CachedValuesManager.getManager(myClass.getProject());
final Object[] dependencies = {PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTreeChangeTracker};
myFieldsCache = cache = manager.createCachedValue(new CachedValueProvider<PsiField[]>() {
@Override
public Result<PsiField[]> compute() {
return Result.create(getAllFields(), dependencies);
}
}, false);
}
final PsiField[] fields = cache.getValue();
return fields != null ? fields : PsiField.EMPTY_ARRAY;
}
示例14: 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>() {
@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();
}
示例15: 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) {
synchronized (PsiLock.LOCK) { // we depend on targetFile and entityRef
CachedValue<PsiElement> value = entityRef.getUserData(PARSED_DECL_KEY);
// return entityDecl.parse(targetFile, type);
if (value == null) {
value = CachedValuesManager.getManager(entityDecl.getProject()).createCachedValue(new CachedValueProvider<PsiElement>() {
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();
}
}