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


Java CachedValue.getValue方法代码示例

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

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

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

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

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

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

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

示例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();
}
 
开发者ID:Haehnchen,项目名称:idea-php-shopware-plugin,代码行数:17,代码来源:SubscriberIndexUtil.java

示例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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:GrGdkMethodImpl.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ClassInnerStuffCache.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:ClassInnerStuffCache.java

示例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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:DomModelCache.java

示例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();
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:XmlPsiUtil.java


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