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


Java CachedValuesManager类代码示例

本文整理汇总了Java中com.intellij.psi.util.CachedValuesManager的典型用法代码示例。如果您正苦于以下问题:Java CachedValuesManager类的具体用法?Java CachedValuesManager怎么用?Java CachedValuesManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CachedValuesManager类属于com.intellij.psi.util包,在下文中一共展示了CachedValuesManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getResolvedProperty

import com.intellij.psi.util.CachedValuesManager; //导入依赖的package包/类
@Nullable
private static IProperty getResolvedProperty(@NotNull final XmlAttributeValue codeValue) {
    return CachedValuesManager.getCachedValue(codeValue, KEY, () -> {
        List<IProperty> allProperties = new SmartList<>();
        for (PsiReference nextRef : codeValue.getReferences()) {
            if (nextRef instanceof PsiPolyVariantReference) {
                Arrays.stream(((PsiPolyVariantReference) nextRef).multiResolve(false))
                      .filter(ResolveResult::isValidResult)
                      .map(ResolveResult::getElement)
                      .map(o -> ObjectUtils.tryCast(o, IProperty.class))
                      .filter(Objects::nonNull)
                      .forEach(allProperties::add);
            } else {
                Optional.ofNullable(nextRef.resolve())
                        .map(o -> ObjectUtils.tryCast(o, IProperty.class))
                        .ifPresent(allProperties::add);
            }
        }

        IProperty theChosenOne = chooseForLocale(allProperties);
        return new CachedValueProvider.Result<>(theChosenOne, PsiModificationTracker.MODIFICATION_COUNT);
    });
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:24,代码来源:JspPropertyFoldingBuilder.java

示例2: getTypeSystemMeta

import com.intellij.psi.util.CachedValuesManager; //导入依赖的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

示例3: doGetExternalModel

import com.intellij.psi.util.CachedValuesManager; //导入依赖的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

示例4: getCatberryVersion

import com.intellij.psi.util.CachedValuesManager; //导入依赖的package包/类
@Nullable
private String getCatberryVersion() {
  if (DumbService.isDumb(project))
    return null;

  final NotNullLazyValue<ModificationTracker> tracker = getCatberryTracker();
  return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<String>() {
    @Nullable
    @Override
    public Result<String> compute() {
      VirtualFile vf = project.getBaseDir().findChild("package.json");
      if (vf == null)
        return Result.create(null, tracker.getValue());
      final JsonFile file = (JsonFile) PsiManager.getInstance(project).findFile(vf);
      if (file == null || file.getTopLevelValue()==null)
        return Result.create(null, tracker.getValue());
      JsonValue value = JsonPsiUtil.findPropertyValue(file.getTopLevelValue(), "dependencies/catberry");
      if (value != null)
        return Result.create(value.getText(), file);
      return Result.create(null, tracker.getValue());
    }
  });
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:24,代码来源:CatberryProjectConfigurationManager.java

示例5: getComponentsDirectories

import com.intellij.psi.util.CachedValuesManager; //导入依赖的package包/类
@NotNull
public PsiDirectory[] getComponentsDirectories() {
  if (DumbService.isDumb(project))
    return new PsiDirectory[0];

  final NotNullLazyValue<ModificationTracker> tracker = getCatberryTracker();
  ComponentsDirectoriesProvider provider = new ComponentsDirectoriesProvider(project, tracker);
  String[] res = CachedValuesManager.getManager(project).getCachedValue(project, provider);

  List<PsiDirectory> result = new ArrayList<PsiDirectory>(res.length);
  for(String path : res) {
    VirtualFile virtualFile = project.getBaseDir().findFileByRelativePath(path);
    if(virtualFile == null)
      continue;
    PsiManager manager = PsiManager.getInstance(project);
    PsiDirectory dir = manager.findDirectory(virtualFile);
    if(dir != null)
      result.add(dir);
  }
  return result.toArray(new PsiDirectory[result.size()]);
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:22,代码来源:CatberryProjectConfigurationManager.java

示例6: JavaConstantExpressionEvaluator

import com.intellij.psi.util.CachedValuesManager; //导入依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:JavaConstantExpressionEvaluator.java

示例7: PsiDisjunctionType

import com.intellij.psi.util.CachedValuesManager; //导入依赖的package包/类
public PsiDisjunctionType(@NotNull List<PsiType> types, @NotNull PsiManager psiManager) {
  super(PsiAnnotation.EMPTY_ARRAY);

  myManager = psiManager;
  myTypes = Collections.unmodifiableList(types);

  myLubCache = CachedValuesManager.getManager(myManager.getProject()).createCachedValue(new CachedValueProvider<PsiType>() {
    @Override
    public Result<PsiType> compute() {
      PsiType lub = myTypes.get(0);
      for (int i = 1; i < myTypes.size(); i++) {
        lub = GenericsUtil.getLeastUpperBound(lub, myTypes.get(i), myManager);
        if (lub == null) {
          lub = PsiType.getJavaLangObject(myManager, GlobalSearchScope.allScope(myManager.getProject()));
          break;
        }
      }
      return Result.create(lub, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
    }
  }, false);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PsiDisjunctionType.java

示例8: inferContracts

import com.intellij.psi.util.CachedValuesManager; //导入依赖的package包/类
@NotNull
public static List<MethodContract> inferContracts(@NotNull final PsiMethod method) {
  if (!InferenceFromSourceUtil.shouldInferFromSource(method)) {
    return Collections.emptyList();
  }
  
  return CachedValuesManager.getCachedValue(method, new CachedValueProvider<List<MethodContract>>() {
    @Nullable
    @Override
    public Result<List<MethodContract>> compute() {
      List<MethodContract> result = RecursionManager.doPreventingRecursion(method, true, new Computable<List<MethodContract>>() {
        @Override
        public List<MethodContract> compute() {
          return new ContractInferenceInterpreter(method).inferContracts();
        }
      });
      if (result == null) result = Collections.emptyList();
      return Result.create(result, method, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ContractInference.java

示例9: inferNullity

import com.intellij.psi.util.CachedValuesManager; //导入依赖的package包/类
public static Nullness inferNullity(final PsiMethod method) {
  if (!InferenceFromSourceUtil.shouldInferFromSource(method)) {
    return Nullness.UNKNOWN;
  }

  PsiType type = method.getReturnType();
  if (type == null || type instanceof PsiPrimitiveType) {
    return Nullness.UNKNOWN;
  }

  return CachedValuesManager.getCachedValue(method, new CachedValueProvider<Nullness>() {
    @Nullable
    @Override
    public Result<Nullness> compute() {
      Nullness result = RecursionManager.doPreventingRecursion(method, true, new Computable<Nullness>() {
        @Override
        public Nullness compute() {
          return doInferNullity(method);
        }
      });
      if (result == null) result = Nullness.UNKNOWN;
      return Result.create(result, method, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:NullityInference.java

示例10: inferPurity

import com.intellij.psi.util.CachedValuesManager; //导入依赖的package包/类
public static boolean inferPurity(@NotNull final PsiMethod method) {
  if (!InferenceFromSourceUtil.shouldInferFromSource(method) ||
      method.getReturnType() == PsiType.VOID ||
      method.getBody() == null ||
      method.isConstructor() || 
      PropertyUtil.isSimpleGetter(method)) {
    return false;
  }

  return CachedValuesManager.getCachedValue(method, new CachedValueProvider<Boolean>() {
    @Nullable
    @Override
    public Result<Boolean> compute() {
      boolean pure = RecursionManager.doPreventingRecursion(method, true, new Computable<Boolean>() {
        @Override
        public Boolean compute() {
          return doInferPurity(method);
        }
      }) == Boolean.TRUE;
      return Result.create(pure, method);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PurityInference.java

示例11: getFileToArtifactsMap

import com.intellij.psi.util.CachedValuesManager; //导入依赖的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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ArtifactBySourceFileFinderImpl.java

示例12: getModuleIndex

import com.intellij.psi.util.CachedValuesManager; //导入依赖的package包/类
private static ModuleIndex getModuleIndex(final Project project) {
  return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<ModuleIndex>() {
      @Nullable
      @Override
      public Result<ModuleIndex> compute() {
        ModuleIndex index = new ModuleIndex();
        for (Module module : ModuleManager.getInstance(project).getModules()) {
          for (OrderEntry orderEntry : ModuleRootManager.getInstance(module).getOrderEntries()) {
            if (orderEntry instanceof ModuleOrderEntry) {
              Module referenced = ((ModuleOrderEntry)orderEntry).getModule();
              if (referenced != null) {
                MultiMap<Module, Module> map = ((ModuleOrderEntry)orderEntry).isExported() ? index.exportingUsages : index.plainUsages;
                map.putValue(referenced, module);
              }
            }
          }
        }
        return Result.create(index, ProjectRootManager.getInstance(project));
      }
    });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ModuleWithDependentsScope.java

示例13: compute

import com.intellij.psi.util.CachedValuesManager; //导入依赖的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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ArbitraryPlaceUrlReferenceProvider.java

示例14: _getOrCreateProblemsHolder

import com.intellij.psi.util.CachedValuesManager; //导入依赖的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

示例15: invoke

import com.intellij.psi.util.CachedValuesManager; //导入依赖的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());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GetInvocation.java


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