本文整理汇总了Java中com.intellij.psi.util.CachedValuesManager.createCachedValue方法的典型用法代码示例。如果您正苦于以下问题:Java CachedValuesManager.createCachedValue方法的具体用法?Java CachedValuesManager.createCachedValue怎么用?Java CachedValuesManager.createCachedValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.CachedValuesManager
的用法示例。
在下文中一共展示了CachedValuesManager.createCachedValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCachedValue
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的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();
}
示例2: getCachedSchema
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
public static Schema getCachedSchema(final XmlFile descriptorFile) {
CachedValue<Schema> value = descriptorFile.getUserData(SCHEMA_KEY);
if (value == null) {
final CachedValueProvider<Schema> provider = new CachedValueProvider<Schema>() {
@Override
public Result<Schema> compute() {
final InputSource inputSource = makeInputSource(descriptorFile);
try {
final Schema schema = new MySchemaReader(descriptorFile).createSchema(inputSource, EMPTY_PROPS);
final PsiElementProcessor.CollectElements<XmlFile> processor = new PsiElementProcessor.CollectElements<XmlFile>();
RelaxIncludeIndex.processForwardDependencies(descriptorFile, processor);
if (processor.getCollection().size() > 0) {
return Result.create(schema, processor.toArray(), descriptorFile);
} else {
return Result.createSingleDependency(schema, descriptorFile);
}
} catch (Exception e) {
LOG.info(e);
return Result.createSingleDependency(null, descriptorFile);
}
}
};
final CachedValuesManager mgr = CachedValuesManager.getManager(descriptorFile.getProject());
value = mgr.createCachedValue(provider, false);
descriptorFile.putUserData(SCHEMA_KEY, value);
}
return value.getValue();
}
示例3: getAllVariants
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@Nullable
public static Map<String, Set<Define>> getAllVariants(Grammar scope) {
final PsiElement psiElement = scope.getPsiElement();
if (psiElement == null || !psiElement.isValid()) return null;
final CachedValuesManager manager = CachedValuesManager.getManager(psiElement.getProject());
CachedValue<Map<String, Set<Define>>> data = psiElement.getUserData(KEY);
if (data == null || !((DefinitionResolver)data.getValueProvider()).isValid()) {
final DefinitionResolver resolver = new DefinitionResolver(scope);
data = manager.createCachedValue(resolver, false);
psiElement.putUserData(KEY, data);
}
return data.getValue();
}
示例4: getSchema
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@Override
public XmlFile getSchema(@NotNull @NonNls String url, @Nullable final Module module, @NotNull PsiFile baseFile) {
if (module == null || AndroidFacet.getInstance(module) == null) return null;
Map<String, CachedValue<XmlFile>> descriptors = module.getUserData(DESCRIPTORS_MAP_IN_MODULE);
if (descriptors == null) {
descriptors = new THashMap<String, CachedValue<XmlFile>>();
module.putUserData(DESCRIPTORS_MAP_IN_MODULE, descriptors);
}
CachedValue<XmlFile> reference = descriptors.get(url);
if (reference != null) {
return reference.getValue();
}
CachedValuesManager manager = CachedValuesManager.getManager(module.getProject());
reference = manager.createCachedValue(new CachedValueProvider<XmlFile>() {
@Override
public Result<XmlFile> compute() {
final URL resource = AndroidXmlSchemaProvider.class.getResource("android.xsd");
final VirtualFile fileByURL = VfsUtil.findFileByURL(resource);
XmlFile result = (XmlFile)PsiManager.getInstance(module.getProject()).findFile(fileByURL).copy();
return new Result<XmlFile>(result, PsiModificationTracker.MODIFICATION_COUNT);
}
}, false);
descriptors.put(url, reference);
return reference.getValue();
}