当前位置: 首页>>代码示例>>Java>>正文


Java CachedValuesManager.createCachedValue方法代码示例

本文整理汇总了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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DomModelCache.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:RngParser.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:DefinitionResolver.java

示例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();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:AndroidXmlSchemaProvider.java


注:本文中的com.intellij.psi.util.CachedValuesManager.createCachedValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。