本文整理汇总了Java中com.intellij.psi.util.CachedValuesManager.getCachedValue方法的典型用法代码示例。如果您正苦于以下问题:Java CachedValuesManager.getCachedValue方法的具体用法?Java CachedValuesManager.getCachedValue怎么用?Java CachedValuesManager.getCachedValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.CachedValuesManager
的用法示例。
在下文中一共展示了CachedValuesManager.getCachedValue方法的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: getNavigationElement
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@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);
}
});
}
示例3: 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);
}
});
}
示例4: getMethods
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@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);
}
});
}
示例5: getPropertiesFile
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
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;
}
示例6: getOwner
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
private PsiVariable getOwner() {
return CachedValuesManager.getCachedValue(this, new CachedValueProvider<PsiVariable>() {
@Override
public Result<PsiVariable> compute() {
final GroovyPsiElement context = PsiTreeUtil.getParentOfType(GrClosableBlockImpl.this, GrTypeDefinition.class, GrClosableBlock.class, GroovyFile.class);
final PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
PsiType type = null;
if (context instanceof GrTypeDefinition) {
type = factory.createType((PsiClass)context);
}
else if (context instanceof GrClosableBlock) {
type = GrClosureType.create((GrClosableBlock)context, true);
}
else if (context instanceof GroovyFile) {
final PsiClass scriptClass = ((GroovyFile)context).getScriptClass();
if (scriptClass != null && GroovyNamesUtil.isIdentifier(scriptClass.getName())) type = factory.createType(scriptClass);
}
if (type == null) {
type = TypesUtil.getJavaLangObject(GrClosableBlockImpl.this);
}
PsiVariable owner = new GrLightVariable(getManager(), OWNER_NAME, type, GrClosableBlockImpl.this);
return Result.create(owner, PsiModificationTracker.MODIFICATION_COUNT);
}
});
}
示例7: findWritableProperties
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@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();
}
示例8: getWrappedPropertyType
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@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);
});
}
示例9: getSetterArgumentType
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@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);
});
}
示例10: getCachedValue
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@Override
public <T> T getCachedValue(@NotNull GroovyPsiElement element, @NotNull final Computable<T> computable) {
CachedValuesManager manager = CachedValuesManager.getManager(element.getProject());
Key<CachedValue<T>> key = manager.getKeyForClass(computable.getClass());
return manager.getCachedValue(element, key, new CachedValueProvider<T>() {
@Nullable
@Override
public Result<T> compute() {
return Result.create(computable.compute(), PsiModificationTracker.MODIFICATION_COUNT);
}
}, false);
}
示例11: findGrab
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
private static PsiAnnotation findGrab(final PsiFile file) {
if (!(file instanceof GroovyFile)) return null;
return CachedValuesManager.getCachedValue(file, new CachedValueProvider<PsiAnnotation>() {
@Nullable
@Override
public Result<PsiAnnotation> compute() {
PsiClass grab = JavaPsiFacade.getInstance(file.getProject()).findClass(GrabAnnos.GRAB_ANNO, file.getResolveScope());
final Ref<PsiAnnotation> result = Ref.create();
if (grab != null) {
ReferencesSearch.search(grab, new LocalSearchScope(file)).forEach(new Processor<PsiReference>() {
@Override
public boolean process(PsiReference reference) {
if (reference instanceof GrCodeReferenceElement) {
PsiElement parent = ((GrCodeReferenceElement)reference).getParent();
if (parent instanceof PsiAnnotation) {
result.set((PsiAnnotation)parent);
return false;
}
}
return true;
}
});
}
return Result.create(result.get(), file);
}
});
}
示例12: getAnnotations
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
/**
* Returns all annotations for <code>listOwner</code>, possibly walking up the method hierarchy.
*
* @see com.intellij.codeInsight.AnnotationUtil#isAnnotated(com.intellij.psi.PsiModifierListOwner, java.lang.String, boolean)
*/
private static PsiAnnotation[] getAnnotations(@NotNull final PsiModifierListOwner listOwner, final boolean inHierarchy) {
final PsiModifierList modifierList = listOwner.getModifierList();
if (!inHierarchy) {
return modifierList == null ? PsiAnnotation.EMPTY_ARRAY : modifierList.getAnnotations();
}
return CachedValuesManager.getCachedValue(listOwner, new CachedValueProvider<PsiAnnotation[]>() {
@Nullable
@Override
public Result<PsiAnnotation[]> compute() {
return Result.create(getHierarchyAnnotations(listOwner), PsiModificationTracker.MODIFICATION_COUNT);
}
});
}
示例13: getName
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@Override
public String getName() {
return CachedValuesManager.getCachedValue(this, new CachedValueProvider<String>() {
@Nullable
@Override
public Result<String> compute() {
return Result.create(calcName(),
getContainingFile(),
getContainingFile().getNavigationElement(),
FileIndexFacade.getInstance(getProject()).getRootModificationTracker(),
DumbService.getInstance(getProject()).getModificationTracker());
}
});
}
示例14: getConstructors
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@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);
}
});
}
示例15: getFields
import com.intellij.psi.util.CachedValuesManager; //导入方法依赖的package包/类
@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);
}
});
}