Java 类com.intellij.psi.util.CachedValueProvider 实例源码

项目:hybris-integration-intellij-idea-plugin    文件:JspPropertyFoldingBuilder.java   
@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);
    });
}
项目:hybris-integration-intellij-idea-plugin    文件:TSMetaModelAccessImpl.java   
@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));
}
项目:hybris-integration-intellij-idea-plugin    文件:TSMetaModelAccessImpl.java   
@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();
}
项目:catberry-idea-plugin    文件:CatberryProjectConfigurationManager.java   
@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());
    }
  });
}
项目:intellij-ce-playground    文件:ClsFileImpl.java   
@SuppressWarnings("deprecation")
@Override
@NotNull
public PsiElement getNavigationElement() {
  for (ClsCustomNavigationPolicy customNavigationPolicy : Extensions.getExtensions(ClsCustomNavigationPolicy.EP_NAME)) {
    if (customNavigationPolicy instanceof ClsCustomNavigationPolicyEx) {
      PsiFile navigationElement = ((ClsCustomNavigationPolicyEx)customNavigationPolicy).getFileNavigationElement(this);
      if (navigationElement != null) {
        return navigationElement;
      }
    }
  }

  return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiElement>() {
    @Nullable
    @Override
    public Result<PsiElement> compute() {
      PsiElement target = JavaPsiImplementationHelper.getInstance(getProject()).getClsFileNavigationElement(ClsFileImpl.this);
      ModificationTracker tracker = FileIndexFacade.getInstance(getProject()).getRootModificationTracker();
      return Result.create(target, ClsFileImpl.this, target.getContainingFile(), tracker);
    }
  });
}
项目:intellij-ce-playground    文件:GroovyScriptClass.java   
@Override
@NotNull
public PsiMethod[] getMethods() {
  return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiMethod[]>() {
    @Nullable
    @Override
    public Result<PsiMethod[]> compute() {
      if (!myInitialized) {
        initMethods();
      }

      PsiMethod[] methods = myFile.getMethods();

      int addMain = hasMain(methods) ? 0 : 1;
      int addRun = hasRun(methods) ? 0 : 1;

      PsiMethod[] result = initMethods(methods, addMain, addRun);
      return Result.create(result, myFile);
    }
  });
}
项目:intellij-ce-playground    文件:ContractInference.java   
@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);
    }
  });
}
项目:intellij-ce-playground    文件:ControlFlowUtils.java   
public static Set<GrExpression> getAllReturnValues(@NotNull final GrControlFlowOwner block) {
  return CachedValuesManager.getCachedValue(block, new CachedValueProvider<Set<GrExpression>>() {
    @Override
    public Result<Set<GrExpression>> compute() {
      final Set<GrExpression> result = new HashSet<GrExpression>();
      visitAllExitPoints(block, new ExitPointVisitor() {
        @Override
        public boolean visitExitPoint(Instruction instruction, @Nullable GrExpression returnValue) {
          ContainerUtil.addIfNotNull(result, returnValue);
          return true;
        }
      });
      return Result.create(result, block);
    }
  });
}
项目:intellij-ce-playground    文件:PurityInference.java   
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);
    }
  });
}
项目:intellij-ce-playground    文件:ArtifactBySourceFileFinderImpl.java   
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;
}
项目:intellij-ce-playground    文件:GroovyHotSwapper.java   
private static boolean containsGroovyClasses(final Project project) {
  return CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<Boolean>() {
    @Nullable
    @Override
    public Result<Boolean> compute() {
      AccessToken accessToken = ReadAction.start();
      try {
        return Result.create(FileTypeIndex.containsFileOfType(GroovyFileType.GROOVY_FILE_TYPE, GlobalSearchScope.projectScope(project)),
                             PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
      }
      finally {
        accessToken.finish();
      }
    }
  });
}
项目:intellij-ce-playground    文件:CachedValueChecker.java   
static void checkProvider(CachedValueProvider provider, UserDataHolder userDataHolder) {
  if (!DO_CHECKS) return;

  Class<? extends CachedValueProvider> providerClass = provider.getClass();
  if (!ourCheckedClasses.add(providerClass)) return;

  for (Field field : providerClass.getDeclaredFields()) {
    try {
      field.setAccessible(true);
      Object o = field.get(provider);
      if (o instanceof PsiElement && o != userDataHolder) {
        LOG.error("Incorrect CachedValue use. Provider references PSI, causing memory leaks and possible invalid element access: field " + field.getName() + " of " + provider);
        return;
      }
    }
    catch (IllegalAccessException e) {
      LOG.error(e);
    }
  }
}
项目:intellij-ce-playground    文件:FoldingUpdate.java   
private static CachedValueProvider.Result<Runnable> getUpdateResult(PsiFile file,
                                                                    @NotNull Document document,
                                                                    boolean quick,
                                                                    final Project project,
                                                                    final Editor editor,
                                                                    final boolean applyDefaultState) {

  final FoldingMap elementsToFoldMap = getFoldingsFor(file, document, quick);
  final UpdateFoldRegionsOperation operation = new UpdateFoldRegionsOperation(project, editor, file, elementsToFoldMap,
                                                                              applyDefaultState ? EXCEPT_CARET_REGION : NO, false);
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      editor.getFoldingModel().runBatchFoldingOperationDoNotCollapseCaret(operation);
    }
  };
  Set<Object> dependencies = new HashSet<Object>();
  dependencies.add(document);
  for (FoldingDescriptor descriptor : elementsToFoldMap.values()) {
    dependencies.addAll(descriptor.getDependencies());
  }
  return CachedValueProvider.Result.create(runnable, ArrayUtil.toObjectArray(dependencies));
}
项目:intellij-ce-playground    文件:GrGdkMethodImpl.java   
@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();
}
项目:intellij-ce-playground    文件:ProjectFacetManagerImpl.java   
public ProjectFacetManagerImpl(Project project) {
  myProject = project;
  myCachedValueProvider = new ParameterizedCachedValueProvider<Boolean, FacetTypeId<?>>() {
    @Override
    public CachedValueProvider.Result<Boolean> compute(FacetTypeId<?> param) {
      boolean result = false;
      for (Module module : ModuleManager.getInstance(myProject).getModules()) {
        if (!FacetManager.getInstance(module).getFacetsByType(param).isEmpty()) {
          result = true;
          break;
        }
      }
      return CachedValueProvider.Result.create(result, FacetFinder.getInstance(myProject).getAllFacetsOfTypeModificationTracker(param));
    }
  };
}
项目:intellij-ce-playground    文件:ArbitraryPlaceUrlReferenceProvider.java   
@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);
}
项目:intellij-ce-playground    文件:InjectedPsiCachedValueProvider.java   
@Override
public CachedValueProvider.Result<MultiHostRegistrarImpl> compute(PsiElement element) {
  PsiFile hostPsiFile = element.getContainingFile();
  if (hostPsiFile == null) return null;
  FileViewProvider viewProvider = hostPsiFile.getViewProvider();
  final DocumentEx hostDocument = (DocumentEx)viewProvider.getDocument();
  if (hostDocument == null) return null;

  PsiManager psiManager = viewProvider.getManager();
  final Project project = psiManager.getProject();
  InjectedLanguageManagerImpl injectedManager = InjectedLanguageManagerImpl.getInstanceImpl(project);

  final MultiHostRegistrarImpl result = doCompute(element, injectedManager, project, hostPsiFile);

  return CachedValueProvider.Result.create(result, PsiModificationTracker.MODIFICATION_COUNT, hostDocument);
}
项目:intellij-ce-playground    文件:ExternalResourceManagerExImpl.java   
@Nullable
@Override
public CachedValueProvider.Result<MultiMap<String, String>> compute() {
  MultiMap<String, String> result = new MultiMap<String, String>();

  Collection<Map<String, Resource>> values = myStandardResources.getValue().values();
  for (Map<String, Resource> map : values) {
    for (Map.Entry<String, Resource> entry : map.entrySet()) {
      String url = entry.getValue().getResourceUrl();
      if (url != null) {
        VirtualFile file = VfsUtilCore.findRelativeFile(url, null);
        if (file != null) {
          String namespace = XmlNamespaceIndex.computeNamespace(file);
          if (namespace != null) {
            result.putValue(namespace, entry.getKey());
          }
        }
      }
    }
  }
  return CachedValueProvider.Result.create(result, ExternalResourceManagerExImpl.this);
}
项目:intellij-ce-playground    文件:XmlPsiUtil.java   
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();
}
项目:intellij-ce-playground    文件:MvcFramework.java   
@Nullable
public static MvcFramework getInstance(@Nullable final Module module) {
  if (module == null) {
    return null;
  }

  final Project project = module.getProject();

  return CachedValuesManager.getManager(project).getCachedValue(module, new CachedValueProvider<MvcFramework>() {
    @Override
    public Result<MvcFramework> compute() {
      final ModificationTracker tracker = MvcModuleStructureSynchronizer.getInstance(project).getFileAndRootsModificationTracker();
      for (final MvcFramework framework : EP_NAME.getExtensions()) {
        if (framework.hasSupport(module)) {
          return Result.create(framework, tracker);
        }
      }
      return Result.create(null, tracker);

    }
  });
}
项目:intellij-ce-playground    文件:XmlNSDescriptorImpl.java   
private CachedValue<TypeDescriptor> createAndPutTypesCachedValue(final XmlTag tag, final Pair<QNameKey, XmlTag> pair) {
  final CachedValue<TypeDescriptor> value = CachedValuesManager.getManager(tag.getProject()).createCachedValue(
    new CachedValueProvider<TypeDescriptor>() {
      @Override
      public CachedValueProvider.Result<TypeDescriptor> compute() {
        final String name = tag.getAttributeValue("name");

        if (name != null &&
            pair.first != null &&
            pair.first.first != null &&
            !name.equals(XmlUtil.findLocalNameByQualifiedName(pair.first.first))
          ) {
          myTypesMap.remove(pair);
          return new Result<TypeDescriptor>(null, PsiModificationTracker.MODIFICATION_COUNT);
        }
        final ComplexTypeDescriptor complexTypeDescriptor = new ComplexTypeDescriptor(XmlNSDescriptorImpl.this, tag);
        return new Result<TypeDescriptor>(complexTypeDescriptor, tag);
      }
    }, false);
  myTypesMap.put(pair, value);
  return value;
}
项目:intellij-ce-playground    文件:AndroidFacet.java   
@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();
  }
}
项目:intellij-ce-playground    文件:DataBindingProjectComponent.java   
public DataBindingProjectComponent(final Project project) {
  myProject = project;
  myDataBindingEnabledModules = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<AndroidFacet[]>() {
    @Nullable
    @Override
    public Result<AndroidFacet[]> compute() {
      Module[] modules = ModuleManager.getInstance(myProject).getModules();
      List<AndroidFacet> facets = new ArrayList<AndroidFacet>();
      for (Module module : modules) {
        AndroidFacet facet = AndroidFacet.getInstance(module);
        if (facet == null) {
          continue;
        }
        if (facet.isDataBindingEnabled()) {
          facets.add(facet);
        }
      }
      myModificationCount.incrementAndGet();
      return Result.create(facets.toArray(new AndroidFacet[facets.size()]), DataBindingUtil.DATA_BINDING_ENABLED_TRACKER, ModuleManager.getInstance(project));
    }
  }, false);
}
项目:intellij-ce-playground    文件:BrShortNamesCache.java   
public BrShortNamesCache(DataBindingProjectComponent dataBindingProjectComponent) {
  myComponent = dataBindingProjectComponent;
  myAllFieldNamesCache = CachedValuesManager.getManager(myComponent.getProject()).createCachedValue(new CachedValueProvider<String[]>() {
    @Nullable
    @Override
    public Result<String[]> compute() {
      AndroidFacet[] facets = myComponent.getDataBindingEnabledFacets();
      String[] result;
      if (facets.length == 0) {
        result = ArrayUtil.EMPTY_STRING_ARRAY;
      } else {
        Set<String> allFields = Sets.newHashSet();
        for (AndroidFacet facet : facets) {
          DataBindingUtil.LightBrClass brClass = DataBindingUtil.getOrCreateBrClassFor(facet);
          Collections.addAll(allFields, brClass.getAllFieldNames());
        }
        result = ArrayUtil.toStringArray(allFields);
      }
      return Result.create(result, myComponent);
    }
  }, false);
}
项目:intellij-ce-playground    文件:BrClassFinder.java   
public BrClassFinder(DataBindingProjectComponent component) {
  myComponent = component;
  myClassByPackageCache = CachedValuesManager.getManager(component.getProject()).createCachedValue(
    new CachedValueProvider<Map<String, PsiClass>>() {
      @Nullable
      @Override
      public Result<Map<String, PsiClass>> compute() {
        Map<String, PsiClass> classes = new HashMap<String, PsiClass>();
        for (AndroidFacet facet : myComponent.getDataBindingEnabledFacets()) {
          if (facet.isDataBindingEnabled()) {
            classes.put(DataBindingUtil.getBrQualifiedName(facet), DataBindingUtil.getOrCreateBrClassFor(facet));
          }
        }
        return Result.create(classes, myComponent);
      }
    }, false);
}
项目:intellij-ce-playground    文件:XmlPropertiesFileImpl.java   
public static PropertiesFile getPropertiesFile(final PsiFile file) {
  CachedValuesManager manager = CachedValuesManager.getManager(file.getProject());
  if (file instanceof XmlFile) {
    return manager.getCachedValue(file, KEY,
                                  new CachedValueProvider<PropertiesFile>() {
                                    @Override
                                    public Result<PropertiesFile> compute() {
                                      PropertiesFile value =
                                        XmlPropertiesIndex.isPropertiesFile((XmlFile)file)
                                        ? new XmlPropertiesFileImpl((XmlFile)file)
                                        : null;
                                      return Result.create(value, file);
                                    }
                                  }, false
    );
  }
  return null;
}
项目:intellij-spring-assistant    文件:PsiUtil.java   
@NotNull
public static Map<String, PsiMember> findWritableProperties(@Nullable PsiClass psiClass) {
  if (psiClass != null) {
    return CachedValuesManager.getCachedValue(psiClass, () -> CachedValueProvider.Result
        .create(prepareWritableProperties(psiClass), JAVA_STRUCTURE_MODIFICATION_COUNT));
  }
  return Collections.emptyMap();
}
项目:intellij-spring-assistant    文件:PsiUtil.java   
@Nullable
public static PsiType getWrappedPropertyType(final PsiField field) {
  return CachedValuesManager.getCachedValue(field, () -> {
    final PsiType fieldType = field.getType();
    final PsiClassType.ClassResolveResult resolveResult =
        com.intellij.psi.util.PsiUtil.resolveGenericsClassInType(fieldType);
    final PsiClass fieldClass = resolveResult.getElement();
    if (fieldClass == null) {
      final PsiType propertyType = eraseFreeTypeParameters(fieldType, field);
      return CachedValueProvider.Result.create(propertyType, JAVA_STRUCTURE_MODIFICATION_COUNT);
    }
    return CachedValueProvider.Result.create(null, JAVA_STRUCTURE_MODIFICATION_COUNT);
  });
}
项目:intellij-spring-assistant    文件:PsiUtil.java   
@Nullable
private static PsiType getSetterArgumentType(@NotNull PsiMethod method) {
  return CachedValuesManager.getCachedValue(method, () -> {
    final PsiParameter[] parameters = method.getParameterList().getParameters();
    if (!method.hasModifierProperty(STATIC) && parameters.length == 1) {
      final PsiType argumentType = eraseFreeTypeParameters(parameters[0].getType(), method);
      return CachedValueProvider.Result.create(argumentType, JAVA_STRUCTURE_MODIFICATION_COUNT);
    }
    return CachedValueProvider.Result.create(null, JAVA_STRUCTURE_MODIFICATION_COUNT);
  });
}
项目:hybris-integration-intellij-idea-plugin    文件:TSMetaModelAccessImpl.java   
public TSMetaModelAccessImpl(@NotNull final Project project) {
    myCachedValue = CachedValuesManager.getManager(project).createCachedValue(
        () -> ApplicationManager.getApplication().runReadAction(
            (Computable<CachedValueProvider.Result<TSMetaModel>>) () -> {

                final TSMetaModelBuilder builder = new TSMetaModelBuilder(project);
                final TSMetaModelImpl model = builder.buildModel();
                return CachedValueProvider.Result.create(model, builder.getFiles());

            }), false);
}
项目:cup-plugin    文件:CupPsiImplUtil.java   
private static boolean processSymbolsVariants(PsiElement context, Processor<CupSymbolDefinition> processor) {
    final PsiFile file = context.getContainingFile();
    List<CupSymbolDefinition> symbols = CachedValuesManager.getCachedValue(
            file, new CachedValueProvider<List<CupSymbolDefinition>>() {
                @Nullable
                @Override
                public Result<List<CupSymbolDefinition>> compute() {
                    return Result.create(computeDefinitions(file, CupSymbolDefinition.class), file);
                }
            }
    );
    return ContainerUtil.process(symbols, processor);
}
项目:intellij-ce-playground    文件:GrLightField.java   
@Nullable
@Override
public GrAccessorMethod getSetter() {
  return CachedValuesManager.getCachedValue(this, new CachedValueProvider<GrAccessorMethod>() {
    @Nullable
    @Override
    public Result<GrAccessorMethod> compute() {
      return Result.create(GrAccessorMethodImpl.createSetterMethod(GrLightField.this), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
    }
  });
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
public PsiMethod[] getConstructors() {
  return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiMethod[]>() {
    @Nullable
    @Override
    public Result<PsiMethod[]> compute() {
      return Result.create(PsiImplUtil.getConstructors(myClass), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  });
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
public PsiField[] getFields() {
  return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiField[]>() {
    @Nullable
    @Override
    public Result<PsiField[]> compute() {
      return Result.create(getAllFields(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  });
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
public PsiMethod[] getMethods() {
  return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiMethod[]>() {
    @Nullable
    @Override
    public Result<PsiMethod[]> compute() {
      return Result.create(getAllMethods(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  });
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
public PsiClass[] getInnerClasses() {
  return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiClass[]>() {
    @Nullable
    @Override
    public Result<PsiClass[]> compute() {
      return Result.create(getAllInnerClasses(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  });
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@Nullable
public PsiField findFieldByName(String name, boolean checkBases) {
  if (checkBases) {
    return PsiClassImplUtil.findFieldByName(myClass, name, true);
  }
  return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiField>>() {
    @Nullable
    @Override
    public Result<Map<String, PsiField>> compute() {
      return Result.create(getFieldsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  }).get(name);
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@NotNull
public PsiMethod[] findMethodsByName(String name, boolean checkBases) {
  if (checkBases) {
    return PsiClassImplUtil.findMethodsByName(myClass, name, true);
  }
  PsiMethod[] methods = CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiMethod[]>>() {
    @Nullable
    @Override
    public Result<Map<String, PsiMethod[]>> compute() {
      return Result.create(getMethodsMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  }).get(name);
  return methods == null ? PsiMethod.EMPTY_ARRAY : methods;
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@Nullable
public PsiClass findInnerClassByName(final String name, final boolean checkBases) {
  if (checkBases) {
    return PsiClassImplUtil.findInnerByName(myClass, name, true);
  }
  else {
    return CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<Map<String, PsiClass>>() {
      @Nullable
      @Override
      public Result<Map<String, PsiClass>> compute() {
        return Result.create(getInnerClassesMap(), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
      }
    }).get(name);
  }
}
项目:intellij-ce-playground    文件:ClassInnerStuffCache.java   
@Nullable
public PsiMethod getValuesMethod() {
  return !myClass.isEnum() || myClass.getName() == null ? null : CachedValuesManager.getCachedValue(myClass, new CachedValueProvider<PsiMethod>() {
    @Nullable
    @Override
    public Result<PsiMethod> compute() {
      String text = "public static " + myClass.getName() + "[] values() { }";
      return new Result<PsiMethod>(getSyntheticMethod(text), OUT_OF_CODE_BLOCK_MODIFICATION_COUNT, myTracker);
    }
  });
}