コード例 #1
0
 public static boolean hasTest(PsiModifierListOwner element) {
   return CachedValuesManager.getCachedValue(
       element,
       () ->
           CachedValueProvider.Result.create(
               hasTest(element, true), PsiModificationTracker.MODIFICATION_COUNT));
 }
コード例 #2
0
    public CachedValueProvider.Result<VirtualFile[]> compute(PsiFile psiFile) {
      VirtualFile[] value = computeFiles(psiFile, myRuntimeOnly);
      // todo: we need "url modification tracker" for VirtualFile
      Object[] deps = new Object[value.length + 2];
      deps[deps.length - 2] = psiFile;
      deps[deps.length - 1] = VirtualFileManager.getInstance();

      return CachedValueProvider.Result.create(value, deps);
    }
コード例 #3
0
 @NotNull
 @Override
 public List<PyAssignmentStatement> findAttributes() {
   /**
    * TODO: This method if insanely heavy since it unstubs foreign files. Need to save stubs and
    * use them somehow.
    */
   return CachedValuesManager.getManager(getProject())
       .getCachedValue(
           this,
           ATTRIBUTES_KEY,
           () -> {
             final List<PyAssignmentStatement> result = findAttributesStatic(this);
             return CachedValueProvider.Result.create(
                 result, PsiModificationTracker.MODIFICATION_COUNT);
           },
           false);
 }
コード例 #4
0
 @Override
 public CachedValueProvider.Result<PsiExpression> compute(
     Pair<Project, PsiExpression> pair) {
   PsiExpression param = pair.second;
   Project project = pair.first;
   PsiExpression topLevel = getTopLevel(project, param);
   ParameterizedCachedValue<PsiExpression, Pair<Project, PsiExpression>> cachedValue =
       param.getUserData(TOP_LEVEL_EXPRESSION);
   assert cachedValue != null;
   int i = 0;
   for (PsiElement element = param;
       element != topLevel;
       element = element.getParent(), i++) {
     if (i % 10
         == 0) { // optimization: store up link to the top level expression in each 10nth
                 // element
       element.putUserData(TOP_LEVEL_EXPRESSION, cachedValue);
     }
   }
   return CachedValueProvider.Result.create(
       topLevel, PsiManager.getInstance(project).getModificationTracker());
 }