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


Java RecursionGuard.StackStamp方法代码示例

本文整理汇总了Java中com.intellij.openapi.util.RecursionGuard.StackStamp方法的典型用法代码示例。如果您正苦于以下问题:Java RecursionGuard.StackStamp方法的具体用法?Java RecursionGuard.StackStamp怎么用?Java RecursionGuard.StackStamp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.openapi.util.RecursionGuard的用法示例。


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

示例1: getType

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Nullable
public <T extends GroovyPsiElement> PsiType getType(@NotNull T element, @NotNull Function<T, PsiType> calculator) {
  PsiType type = myCalculatedTypes.get(element);
  if (type == null) {
    RecursionGuard.StackStamp stamp = ourGuard.markStack();
    type = calculator.fun(element);
    if (type == null) {
      type = UNKNOWN_TYPE;
    }
    if (stamp.mayCacheNow()) {
      type = ConcurrencyUtil.cacheOrGet(myCalculatedTypes, element, type);
    } else {
      final PsiType alreadyInferred = myCalculatedTypes.get(element);
      if (alreadyInferred != null) {
        type = alreadyInferred;
      }
    }
  }
  if (!type.isValid()) {
    error(element, type);
  }
  return UNKNOWN_TYPE == type ? null : type;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GroovyPsiManager.java

示例2: getConstructors

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@NotNull
public PsiMethod[] getConstructors() {
  PsiMethod[] cached = myConstructors;
  if (cached == null) {
    RecursionGuard.StackStamp stamp = ourGuard.markStack();
    List<PsiMethod> result = new ArrayList<PsiMethod>();
    for (final PsiMethod method : getMethods()) {
      if (method.isConstructor()) {
        addExpandingReflectedMethods(result, method);
      }
    }

    cached = result.toArray(new PsiMethod[result.size()]);
    if (stamp.mayCacheNow()) {
      myConstructors = cached;
    }
  }
  return cached;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:GrTypeDefinitionImpl.java

示例3: getCodeConstructors

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@NotNull
public GrMethod[] getCodeConstructors() {
  GrMethod[] cached = myCodeConstructors;
  if (cached == null) {
    RecursionGuard.StackStamp stamp = ourGuard.markStack();
    List<GrMethod> result = new ArrayList<GrMethod>();
    for (final GrMethod method : getCodeMethods()) {
      if (method.isConstructor()) {
        result.add(method);
      }
    }

    cached = result.toArray(new GrMethod[result.size()]);
    if (stamp.mayCacheNow()) {
      myCodeConstructors = cached;
    }
  }
  return cached;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:GrTypeDefinitionImpl.java

示例4: getType

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Nullable
public <T extends GroovyPsiElement> PsiType getType(@NotNull T element, @NotNull Function<T, PsiType> calculator) {
  PsiType type = myCalculatedTypes.get(element);
  if (type == null) {
    RecursionGuard.StackStamp stamp = ourGuard.markStack();
    type = calculator.fun(element);
    if (type == null) {
      type = UNKNOWN_TYPE;
    }
    if (stamp.mayCacheNow()) {
      type = ConcurrencyUtil.cacheOrGet(myCalculatedTypes, element, type);
    } else {
      final PsiType alreadyInferred = myCalculatedTypes.get(element);
      if (alreadyInferred != null) {
        type = alreadyInferred;
      }
    }
  }
  if (!type.isValid()) {
    LOG.error("Type is invalid: " + type + "; element: " + element + " of class " + element.getClass());
  }
  return UNKNOWN_TYPE == type ? null : type;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:GroovyPsiManager.java

示例5: getSuperClassSubstitutor

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Nullable
static PsiSubstitutor getSuperClassSubstitutor(@NotNull PsiClass derivedClass, @NotNull GlobalSearchScope scope, @NotNull PsiClass superClass)
{
	ScopedClassHierarchy hierarchy = getHierarchy(derivedClass, scope);
	Map<PsiClass, PsiClassType.ClassResolveResult> map = hierarchy.mySupersWithSubstitutors;
	if(map == null)
	{
		map = ContainerUtil.newTroveMap(CLASS_HASHING_STRATEGY);
		RecursionGuard.StackStamp stamp = ourGuard.markStack();
		hierarchy.visitType(JavaPsiFacade.getElementFactory(derivedClass.getProject()).createType(derivedClass, PsiSubstitutor.EMPTY), map);
		if(stamp.mayCacheNow())
		{
			hierarchy.mySupersWithSubstitutors = map;
		}
	}
	PsiClassType.ClassResolveResult resolveResult = map.get(superClass);
	if(resolveResult == null)
	{
		return null;
	}

	PsiClass cachedClass = assertNotNull(resolveResult.getElement());
	PsiSubstitutor cachedSubstitutor = resolveResult.getSubstitutor();
	return cachedClass == superClass ? cachedSubstitutor : mirrorSubstitutor(superClass, cachedClass, cachedSubstitutor);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:ScopedClassHierarchy.java

示例6: getImmediateSupersWithCapturing

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@NotNull
List<PsiClassType.ClassResolveResult> getImmediateSupersWithCapturing()
{
	List<PsiClassType.ClassResolveResult> list = myImmediateSupersWithCapturing;
	if(list == null)
	{
		RecursionGuard.StackStamp stamp = ourGuard.markStack();
		list = ourGuard.doPreventingRecursion(this, true, new Computable<List<PsiClassType.ClassResolveResult>>()
		{
			@Override
			public List<PsiClassType.ClassResolveResult> compute()
			{
				return calcImmediateSupersWithCapturing();
			}
		});
		if(list == null)
		{
			return Collections.emptyList();
		}
		if(stamp.mayCacheNow())
		{
			myImmediateSupersWithCapturing = list;
		}
	}
	return list;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:27,代码来源:ScopedClassHierarchy.java

示例7: getType

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Nullable
public <T extends PsiExpression> PsiType getType(@NotNull T expr, @NotNull Function<T, PsiType> f) {
  final boolean isOverloadCheck = MethodCandidateInfo.isOverloadCheck();
  PsiType type = isOverloadCheck ? null : myCalculatedTypes.get(expr);
  if (type == null) {
    final RecursionGuard.StackStamp dStackStamp = PsiDiamondType.ourDiamondGuard.markStack();
    type = f.fun(expr);
    if (!dStackStamp.mayCacheNow() || isOverloadCheck) {
      return type;
    }
    if (type == null) type = TypeConversionUtil.NULL_TYPE;
    myCalculatedTypes.put(expr, type);

    if (type instanceof PsiClassReferenceType) {
      // convert reference-based class type to the PsiImmediateClassType, since the reference may become invalid
      PsiClassType.ClassResolveResult result = ((PsiClassReferenceType)type).resolveGenerics();
      PsiClass psiClass = result.getElement();
      type = psiClass == null
             ? type // for type with unresolved reference, leave it in the cache
                    // for clients still might be able to retrieve its getCanonicalText() from the reference text
             : new PsiImmediateClassType(psiClass, result.getSubstitutor(), ((PsiClassReferenceType)type).getLanguageLevel(), type.getAnnotations());
    }
  }

  if (!type.isValid()) {
    if (expr.isValid()) {
      PsiJavaCodeReferenceElement refInside = type instanceof PsiClassReferenceType ? ((PsiClassReferenceType)type).getReference() : null;
      @NonNls String typeinfo = type + " (" + type.getClass() + ")" + (refInside == null ? "" : "; ref inside: "+refInside + " ("+refInside.getClass()+") valid:"+refInside.isValid());
      LOG.error("Type is invalid: " + typeinfo + "; expr: '" + expr + "' (" + expr.getClass() + ") is valid");
    }
    else {
      LOG.error("Expression: '"+expr+"' is invalid, must not be used for getType()");
    }
  }

  return type == TypeConversionUtil.NULL_TYPE ? null : type;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:JavaResolveCache.java

示例8: inferTypeForMethodTypeParameterInner

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
private Pair<PsiType, ConstraintType> inferTypeForMethodTypeParameterInner(@NotNull PsiTypeParameter typeParameter,
                                                                                @NotNull PsiParameter[] parameters,
                                                                                @NotNull PsiExpression[] arguments,
                                                                                @NotNull PsiSubstitutor partialSubstitutor,
                                                                                final PsiElement parent,
                                                                                @NotNull ParameterTypeInferencePolicy policy) {
  PsiType[] paramTypes = PsiType.createArray(arguments.length);
  PsiType[] argTypes = PsiType.createArray(arguments.length);
  if (parameters.length > 0) {
    for (int j = 0; j < argTypes.length; j++) {
      final PsiExpression argument = arguments[j];
      if (argument == null) continue;
      if (argument instanceof PsiMethodCallExpression && PsiResolveHelper.ourGuard.currentStack().contains(argument)) continue;

      final RecursionGuard.StackStamp stackStamp = PsiDiamondType.ourDiamondGuard.markStack();
      argTypes[j] = argument.getType();
      if (!stackStamp.mayCacheNow()) {
        argTypes[j] = null;
        continue;
      }

      final PsiParameter parameter = parameters[Math.min(j, parameters.length - 1)];
      if (j >= parameters.length && !parameter.isVarArgs()) break;
      paramTypes[j] = parameter.getType();
      if (paramTypes[j] instanceof PsiEllipsisType) {
        paramTypes[j] = ((PsiEllipsisType)paramTypes[j]).getComponentType();
        if (arguments.length == parameters.length &&
            argTypes[j] instanceof PsiArrayType &&
            !(((PsiArrayType)argTypes[j]).getComponentType() instanceof PsiPrimitiveType)) {
          argTypes[j] = ((PsiArrayType)argTypes[j]).getComponentType();
        }
      }
    }
  }
  return inferTypeForMethodTypeParameterInner(typeParameter, paramTypes, argTypes, partialSubstitutor, parent, policy);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:PsiOldInferenceHelper.java

示例9: getSubstitutor

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@NotNull
public PsiSubstitutor getSubstitutor(boolean includeReturnConstraint) {
  PsiSubstitutor substitutor = myCalcedSubstitutor;
  if (substitutor == null || !includeReturnConstraint && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) || isOverloadCheck()) {
    PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
    PsiMethod method = getElement();
    if (myTypeArguments == null) {
      final RecursionGuard.StackStamp stackStamp = PsiDiamondType.ourDiamondGuard.markStack();

      final PsiSubstitutor inferredSubstitutor = inferTypeArguments(DefaultParameterTypeInferencePolicy.INSTANCE, includeReturnConstraint);

       if (!stackStamp.mayCacheNow() ||
           isOverloadCheck() ||
           !includeReturnConstraint && myLanguageLevel.isAtLeast(LanguageLevel.JDK_1_8) ||
           getMarkerList() != null && PsiResolveHelper.ourGraphGuard.currentStack().contains(getMarkerList().getParent())) {
        return inferredSubstitutor;
      }

      myCalcedSubstitutor = substitutor = inferredSubstitutor;
    }
    else {
      PsiTypeParameter[] typeParams = method.getTypeParameters();
      for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
        incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
      }
      myCalcedSubstitutor = substitutor = incompleteSubstitutor;
    }
  }

  return substitutor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:MethodCandidateInfo.java

示例10: get

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Override
public V get(Object key) {
  final Map<K, V> map = getMap();
  V value = map.get(getKey(key));
  if (value == null) {
    RecursionGuard.StackStamp stamp = ourGuard.markStack();
    value = create((K)key);
    if (stamp.mayCacheNow()) {
      map.put((K)getKey(key), value == null ? (V)NULL : value);
    }
  }
  return value == NULL ? null : value;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:FactoryMap.java

示例11: getSemElements

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Override
@Nullable
public <T extends SemElement> List<T> getSemElements(final SemKey<T> key, @NotNull final PsiElement psi) {
  List<T> cached = _getCachedSemElements(key, true, psi);
  if (cached != null) {
    return cached;
  }

  ensureInitialized();

  RecursionGuard.StackStamp stamp = RecursionManager.createGuard("semService").markStack();

  LinkedHashSet<T> result = new LinkedHashSet<T>();
  final Map<SemKey, List<SemElement>> map = new THashMap<SemKey, List<SemElement>>();
  for (final SemKey each : key.getInheritors()) {
    List<SemElement> list = createSemElements(each, psi);
    map.put(each, list);
    result.addAll((List<T>)list);
  }

  if (stamp.mayCacheNow()) {
    final SemCacheChunk persistent = getOrCreateChunk(psi);
    for (SemKey semKey : map.keySet()) {
      persistent.putSemElements(semKey, map.get(semKey));
    }
  }

  return new ArrayList<T>(result);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:SemServiceImpl.java

示例12: getType

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Nullable
public <T extends PsiExpression> PsiType getType(@NotNull T expr, @NotNull Function<T, PsiType> f) {
  PsiType type = getCachedType(expr);
  if (type == null) {
    final RecursionGuard.StackStamp dStackStamp = PsiDiamondType.ourDiamondGuard.markStack();
    final RecursionGuard.StackStamp gStackStamp = PsiResolveHelper.ourGraphGuard.markStack();
    type = f.fun(expr);
    if (!dStackStamp.mayCacheNow() || !gStackStamp.mayCacheNow()) {
      return type;
    }
    if (type == null) type = TypeConversionUtil.NULL_TYPE;
    Reference<PsiType> ref = new SoftReference<PsiType>(type);
    myCalculatedTypes.put(expr, ref);

    if (type instanceof PsiClassReferenceType) {
      // convert reference-based class type to the PsiImmediateClassType, since the reference may become invalid
      PsiClassType.ClassResolveResult result = ((PsiClassReferenceType)type).resolveGenerics();
      PsiClass psiClass = result.getElement();
      type = psiClass == null
             ? type // for type with unresolved reference, leave it in the cache
                    // for clients still might be able to retrieve its getCanonicalText() from the reference text
             : new PsiImmediateClassType(psiClass, result.getSubstitutor(), ((PsiClassReferenceType)type).getLanguageLevel(), type.getAnnotations());
    }
  }

  if (!type.isValid()) {
    if (expr.isValid()) {
      PsiJavaCodeReferenceElement refInside = type instanceof PsiClassReferenceType ? ((PsiClassReferenceType)type).getReference() : null;
      @NonNls String typeinfo = type + " (" + type.getClass() + ")" + (refInside == null ? "" : "; ref inside: "+refInside + " ("+refInside.getClass()+") valid:"+refInside.isValid());
      LOG.error("Type is invalid: " + typeinfo + "; expr: '" + expr + "' (" + expr.getClass() + ") is valid");
    }
    else {
      LOG.error("Expression: '"+expr+"' is invalid, must not be used for getType()");
    }
  }

  return type == TypeConversionUtil.NULL_TYPE ? null : type;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:39,代码来源:JavaResolveCache.java

示例13: inferTypeForMethodTypeParameterInner

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
private Pair<PsiType, ConstraintType> inferTypeForMethodTypeParameterInner(@NotNull PsiTypeParameter typeParameter,
                                                                                  @NotNull PsiParameter[] parameters,
                                                                                  @NotNull PsiExpression[] arguments,
                                                                                  @NotNull PsiSubstitutor partialSubstitutor,
                                                                                  final PsiElement parent,
                                                                                  @NotNull ParameterTypeInferencePolicy policy) {
  PsiType[] paramTypes = new PsiType[arguments.length];
  PsiType[] argTypes = new PsiType[arguments.length];
  if (parameters.length > 0) {
    for (int j = 0; j < argTypes.length; j++) {
      final PsiExpression argument = arguments[j];
      if (argument == null) continue;
      if (argument instanceof PsiMethodCallExpression && ourGuard.currentStack().contains(argument)) continue;

      final RecursionGuard.StackStamp stackStamp = PsiDiamondType.ourDiamondGuard.markStack();
      argTypes[j] = argument.getType();
      if (!stackStamp.mayCacheNow()) {
        argTypes[j] = null;
        continue;
      }

      final PsiParameter parameter = parameters[Math.min(j, parameters.length - 1)];
      if (j >= parameters.length && !parameter.isVarArgs()) break;
      paramTypes[j] = parameter.getType();
      if (paramTypes[j] instanceof PsiEllipsisType) {
        paramTypes[j] = ((PsiEllipsisType)paramTypes[j]).getComponentType();
        if (arguments.length == parameters.length &&
            argTypes[j] instanceof PsiArrayType &&
            !(((PsiArrayType)argTypes[j]).getComponentType() instanceof PsiPrimitiveType)) {
          argTypes[j] = ((PsiArrayType)argTypes[j]).getComponentType();
        }
      }
    }
  }
  return inferTypeForMethodTypeParameterInner(typeParameter, paramTypes, argTypes, partialSubstitutor, parent, policy);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:PsiResolveHelperImpl.java

示例14: getSubstitutor

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Override
public PsiSubstitutor getSubstitutor() {
  if (myCalcedSubstitutor == null) {
    PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
    PsiMethod method = getElement();
    if (myTypeArguments == null) {
      final RecursionGuard.StackStamp stackStamp = PsiDiamondType.ourDiamondGuard.markStack();

      final PsiSubstitutor inferredSubstitutor = inferTypeArguments(DefaultParameterTypeInferencePolicy.INSTANCE);

       if (!stackStamp.mayCacheNow()) {
        return inferredSubstitutor;
      }

      myCalcedSubstitutor = inferredSubstitutor;
    }
    else {
      PsiTypeParameter[] typeParams = method.getTypeParameters();
      for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
        incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
      }
      myCalcedSubstitutor = incompleteSubstitutor;
    }
  }

  return myCalcedSubstitutor;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:MethodCandidateInfo.java

示例15: getSemElements

import com.intellij.openapi.util.RecursionGuard; //导入方法依赖的package包/类
@Override
@Nullable
public <T extends SemElement> List<T> getSemElements(final SemKey<T> key, @NotNull final PsiElement psi) {
  List<T> cached = _getCachedSemElements(key, true, psi);
  if (cached != null) {
    return cached;
  }

  RecursionGuard.StackStamp stamp = RecursionManager.createGuard("semService").markStack();

  LinkedHashSet<T> result = new LinkedHashSet<T>();
  final Map<SemKey, List<SemElement>> map = new THashMap<SemKey, List<SemElement>>();
  for (final SemKey each : myInheritors.get(key)) {
    List<SemElement> list = createSemElements(each, psi);
    map.put(each, list);
    result.addAll((List<T>)list);
  }

  if (stamp.mayCacheNow()) {
    final SemCacheChunk persistent = getOrCreateChunk(psi);
    for (SemKey semKey : map.keySet()) {
      persistent.putSemElements(semKey, map.get(semKey));
    }
  }

  return new ArrayList<T>(result);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:SemServiceImpl.java


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