mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
a more user-friendly doPreventingRecursion
This commit is contained in:
@@ -56,6 +56,15 @@ public class RecursionManager {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @see RecursionGuard#doPreventingRecursion(Object, boolean, Computable)
|
||||
*/
|
||||
@SuppressWarnings("JavaDoc")
|
||||
@Nullable
|
||||
public static <T> T doPreventingRecursion(@NotNull Object key, boolean memoize, Computable<T> computation) {
|
||||
return createGuard(computation.getClass().getName()).doPreventingRecursion(key, memoize, computation);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param id just some string to separate different recursion prevention policies from each other
|
||||
* @return a helper object which allow you to perform reentrancy-safe computations and check whether caching will be safe.
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ public class TypeInferenceHelper {
|
||||
|
||||
@Nullable
|
||||
public static PsiType getInferredType(@NotNull final GrReferenceExpression refExpr) {
|
||||
return RecursionManager.createGuard("refType").doPreventingRecursion(refExpr, true, new Computable<PsiType>() {
|
||||
return RecursionManager.doPreventingRecursion(refExpr, true, new Computable<PsiType>() {
|
||||
@Override
|
||||
public PsiType compute() {
|
||||
@SuppressWarnings("unchecked") GroovyPsiElement scope =
|
||||
|
||||
+1
-1
@@ -352,7 +352,7 @@ public class GroovyScriptClass extends LightElement implements GrMemberOwner, Sy
|
||||
return CachedValuesManager.getManager(getProject()).getCachedValue(this, new CachedValueProvider<List<GrVariable>>() {
|
||||
@Override
|
||||
public Result<List<GrVariable>> compute() {
|
||||
List<GrVariable> result = RecursionManager.createGuard("groovy.scriptFields").doPreventingRecursion(GroovyScriptClass.this, true, new Computable<List<GrVariable>>() {
|
||||
List<GrVariable> result = RecursionManager.doPreventingRecursion(GroovyScriptClass.this, true, new Computable<List<GrVariable>>() {
|
||||
@Override
|
||||
public List<GrVariable> compute() {
|
||||
final List<GrVariable> result = new ArrayList<GrVariable>();
|
||||
|
||||
@@ -129,7 +129,7 @@ public class GrClassImplUtil {
|
||||
|
||||
@Nullable
|
||||
private static List<PsiClassType> getImplementsFromDelegate(@NotNull final GrTypeDefinition grType, final Set<PsiClass> visited) {
|
||||
return RecursionManager.createGuard("groovyDelegateFields").doPreventingRecursion(grType, true, new Computable<List<PsiClassType>>() {
|
||||
return RecursionManager.doPreventingRecursion(grType, true, new Computable<List<PsiClassType>>() {
|
||||
@Override
|
||||
public List<PsiClassType> compute() {
|
||||
List<PsiClassType> result = new ArrayList<PsiClassType>();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.jetbrains.plugins.groovy.spock;
|
||||
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.RecursionGuard;
|
||||
import com.intellij.openapi.util.RecursionManager;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
@@ -29,8 +28,6 @@ public class SpockVariableDescriptor {
|
||||
|
||||
private PsiVariable myVariable;
|
||||
|
||||
private static final RecursionGuard guard = RecursionManager.createGuard("SpockVariableDescriptor");
|
||||
|
||||
public SpockVariableDescriptor(PsiElement navigationElement, String name) {
|
||||
myName = name;
|
||||
myNavigationElement = navigationElement;
|
||||
@@ -63,7 +60,7 @@ public class SpockVariableDescriptor {
|
||||
if (myVariable == null) {
|
||||
final PsiManager manager = myNavigationElement.getManager();
|
||||
|
||||
PsiType type = guard.doPreventingRecursion(this, true, new Computable<PsiType>() {
|
||||
PsiType type = RecursionManager.doPreventingRecursion(this, true, new Computable<PsiType>() {
|
||||
@Override
|
||||
public PsiType compute() {
|
||||
PsiType res = null;
|
||||
|
||||
@@ -668,7 +668,7 @@ public class XmlUtil {
|
||||
|
||||
final PsiElement[] inclusion = CachedValuesManager.getManager(xincludeTag.getProject()).getCachedValue(xincludeTag, new CachedValueProvider<PsiElement[]>() {
|
||||
public Result<PsiElement[]> compute() {
|
||||
return RecursionManager.createGuard("xinclude").doPreventingRecursion(xincludeTag, true, new Computable<Result<PsiElement[]>>() {
|
||||
return RecursionManager.doPreventingRecursion(xincludeTag, true, new Computable<Result<PsiElement[]>>() {
|
||||
@Override
|
||||
public Result<PsiElement[]> compute() {
|
||||
return computeInclusion(xincludeTag);
|
||||
|
||||
Reference in New Issue
Block a user