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


Java RecursionManager类代码示例

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


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

示例1: inferContracts

import com.intellij.openapi.util.RecursionManager; //导入依赖的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);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:ContractInference.java

示例2: inferNullity

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
public static Nullness inferNullity(final PsiMethod method) {
  if (!InferenceFromSourceUtil.shouldInferFromSource(method)) {
    return Nullness.UNKNOWN;
  }

  PsiType type = method.getReturnType();
  if (type == null || type instanceof PsiPrimitiveType) {
    return Nullness.UNKNOWN;
  }

  return CachedValuesManager.getCachedValue(method, new CachedValueProvider<Nullness>() {
    @Nullable
    @Override
    public Result<Nullness> compute() {
      Nullness result = RecursionManager.doPreventingRecursion(method, true, new Computable<Nullness>() {
        @Override
        public Nullness compute() {
          return doInferNullity(method);
        }
      });
      if (result == null) result = Nullness.UNKNOWN;
      return Result.create(result, method, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:NullityInference.java

示例3: inferPurity

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
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);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:PurityInference.java

示例4: getLeastUpperBoundByVar

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@Nullable
private static PsiType getLeastUpperBoundByVar(@NotNull final GrVariable var) {
  return RecursionManager.doPreventingRecursion(var, false, new NullableComputable<PsiType>() {
    @Override
    public PsiType compute() {
      final Collection<PsiReference> all = ReferencesSearch.search(var, var.getUseScope()).findAll();
      final GrExpression initializer = var.getInitializerGroovy();

      if (initializer == null && all.isEmpty()) {
        return var.getDeclaredType();
      }

      PsiType result = initializer != null ? initializer.getType() : null;

      final PsiManager manager = var.getManager();
      for (PsiReference reference : all) {
        final PsiElement ref = reference.getElement();
        if (ref instanceof GrReferenceExpression && PsiUtil.isLValue(((GrReferenceExpression)ref))) {
          result = TypesUtil.getLeastUpperBoundNullable(result, TypeInferenceHelper.getInitializerTypeFor(ref), manager);
        }
      }

      return result;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GrReassignedLocalVarsChecker.java

示例5: resolveByShape

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@Override
public GroovyResolveResult[] resolveByShape() {
  final InferenceContext context = TypeInferenceHelper.getCurrentContext();
  return context.getCachedValue(this, new Computable<GroovyResolveResult[]>() {
    @Override
    public GroovyResolveResult[] compute() {
      Pair<GrReferenceExpressionImpl, InferenceContext> key = Pair.create(GrReferenceExpressionImpl.this, context);
      GroovyResolveResult[] value = RecursionManager.doPreventingRecursion(key, true, new Computable<GroovyResolveResult[]>() {
        @Override
        public GroovyResolveResult[] compute() {
          return doPolyResolve(false, false);
        }
      });
      return value == null ? GroovyResolveResult.EMPTY_ARRAY : value;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GrReferenceExpressionImpl.java

示例6: failedToBindStubToAst

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
private ASTNode failedToBindStubToAst(@Nonnull PsiFileImpl file, @Nonnull final FileElement fileElement) {
  VirtualFile vFile = file.getVirtualFile();
  StubTree stubTree = file.getStubTree();
  final String stubString = stubTree != null ? ((PsiFileStubImpl)stubTree.getRoot()).printTree() : null;
  final String astString = RecursionManager.doPreventingRecursion("failedToBindStubToAst", true,
                                                                  () -> DebugUtil.treeToString(fileElement, true));

  @NonNls final String message = "Failed to bind stub to AST for element " + getClass() + " in " +
                                 (vFile == null ? "<unknown file>" : vFile.getPath()) +
                                 "\nFile:\n" + file + "@" + System.identityHashCode(file);

  final String creationTraces = ourTraceStubAstBinding ? dumpCreationTraces(fileElement) : null;

  List<Attachment> attachments = new ArrayList<>();
  if (stubString != null) {
    attachments.add(new Attachment("stubTree.txt", stubString));
  }
  if (astString != null) {
    attachments.add(new Attachment("ast.txt", astString));
  }
  if (creationTraces != null) {
    attachments.add(new Attachment("creationTraces.txt", creationTraces));
  }

  throw new RuntimeExceptionWithAttachments(message, attachments.toArray(Attachment.EMPTY_ARRAY));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:StubBasedPsiElementBase.java

示例7: getType

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@NotNull
@Override
public JavaScriptType getType()
{
	final JSExpression initializer = getInitializer();
	if(initializer != null)
	{
		JavaScriptType javaScriptType = RecursionManager.doPreventingRecursion(this, false, new Computable<JavaScriptType>()
		{
			@Override
			@RequiredReadAction
			public JavaScriptType compute()
			{
				return initializer.getType();
			}
		});
		return javaScriptType == null ? JavaScriptType.UNKNOWN : javaScriptType;
	}
	return JavaScriptType.UNKNOWN;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:JSVariableBaseImpl.java

示例8: inferContracts

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@NotNull
public static List<StandardMethodContract> inferContracts(@NotNull PsiMethodImpl method)
{
	if(!InferenceFromSourceUtil.shouldInferFromSource(method))
	{
		return Collections.emptyList();
	}

	return CachedValuesManager.getCachedValue(method, () ->
	{
		MethodData data = ContractInferenceIndexKt.getIndexedData(method);
		List<PreContract> preContracts = data == null ? Collections.emptyList() : data.getContracts();
		List<StandardMethodContract> result = RecursionManager.doPreventingRecursion(method, true, () -> postProcessContracts(method, data, preContracts));
		if(result == null)
		{
			result = Collections.emptyList();
		}
		return CachedValueProvider.Result.create(result, method, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:21,代码来源:ContractInference.java

示例9: inferNullity

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
public static Nullness inferNullity(PsiMethodImpl method)
{
	if(!InferenceFromSourceUtil.shouldInferFromSource(method))
	{
		return Nullness.UNKNOWN;
	}

	PsiType type = method.getReturnType();
	if(type == null || type instanceof PsiPrimitiveType)
	{
		return Nullness.UNKNOWN;
	}

	return CachedValuesManager.getCachedValue(method, () ->
	{
		MethodData data = ContractInferenceIndexKt.getIndexedData(method);
		NullityInferenceResult result = data == null ? null : data.getNullity();
		Nullness nullness = result == null ? null : RecursionManager.doPreventingRecursion(method, true, () -> result.getNullness(method, data.methodBody(method)));
		if(nullness == null)
		{
			nullness = Nullness.UNKNOWN;
		}
		return CachedValueProvider.Result.create(nullness, method, PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT);
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:NullityInference.java

示例10: getInitializerColor

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@Nullable
private static Color getInitializerColor(@NotNull PsiVariable var)
{
	if(!JavaColorProvider.isColorType(var.getType()))
	{
		return null;
	}

	PsiExpression expression = getInitializer(var);
	if(expression instanceof PsiReferenceExpression)
	{
		final PsiElement target = ((PsiReferenceExpression) expression).resolve();
		if(target instanceof PsiVariable)
		{
			return RecursionManager.doPreventingRecursion(expression, true, () -> getInitializerColor((PsiVariable) target));
		}
	}
	return JavaColorProvider.getJavaColorFromExpression(expression);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:VariableLookupItem.java

示例11: getExpressionColor

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@Nullable
private static Color getExpressionColor(@Nullable PsiExpression expression) {
  if (expression instanceof PsiReferenceExpression) {
    final PsiElement target = ((PsiReferenceExpression)expression).resolve();
    if (target instanceof PsiVariable) {
      return RecursionManager.doPreventingRecursion(expression, true, new Computable<Color>() {
        @Override
        public Color compute() {
          return getExpressionColor(((PsiVariable)target).getInitializer());
        }
      });
    }
  }
  return JavaColorProvider.getJavaColorFromExpression(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:VariableLookupItem.java

示例12: getSemElements

import com.intellij.openapi.util.RecursionManager; //导入依赖的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

示例13: compute

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@Override
public Result<PsiElement[]> compute() {
  PsiElement[] result = RecursionManager.doPreventingRecursion(myXincludeTag, true, new NullableComputable<PsiElement[]>() {
    @Override
    public PsiElement[] compute() {
      return computeInclusion(myXincludeTag);
    }
  });
  return Result.create(result == null ? PsiElement.EMPTY_ARRAY : result, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:InclusionProvider.java

示例14: getTypeOf

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@Nullable
public static PsiType getTypeOf(@Nullable final GrExpression expression) {
  if (expression == null) return null;
  return RecursionManager.doPreventingRecursion(expression, true, new Computable<PsiType>() {
    @Override
    public PsiType compute() {
      return expression.getNominalType();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GradleResolverUtil.java

示例15: getCategoryType

import com.intellij.openapi.util.RecursionManager; //导入依赖的package包/类
@Nullable
public static PsiClassType getCategoryType(@NotNull final PsiClass categoryAnnotationOwner) {
  return CachedValuesManager.getCachedValue(categoryAnnotationOwner, new CachedValueProvider<PsiClassType>() {
    @Override
    public Result<PsiClassType> compute() {
      return Result.create(inferCategoryType(categoryAnnotationOwner), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
    }

    @Nullable
    private PsiClassType inferCategoryType(final PsiClass aClass) {
      return RecursionManager.doPreventingRecursion(aClass, true, new NullableComputable<PsiClassType>() {
        @Nullable
        @Override
        public PsiClassType compute() {
          final PsiModifierList modifierList = aClass.getModifierList();
          if (modifierList == null) return null;

          final PsiAnnotation annotation = modifierList.findAnnotation(GroovyCommonClassNames.GROOVY_LANG_CATEGORY);
          if (annotation == null) return null;

          PsiAnnotationMemberValue value = annotation.findAttributeValue("value");
          if (!(value instanceof GrReferenceExpression)) return null;

          if ("class".equals(((GrReferenceExpression)value).getReferenceName())) value = ((GrReferenceExpression)value).getQualifier();
          if (!(value instanceof GrReferenceExpression)) return null;

          final PsiElement resolved = ((GrReferenceExpression)value).resolve();
          if (!(resolved instanceof PsiClass)) return null;

          String className = ((PsiClass)resolved).getQualifiedName();
          if (className == null) className = ((PsiClass)resolved).getName();
          if (className == null) return null;

          return JavaPsiFacade.getElementFactory(aClass.getProject()).createTypeByFQClassName(className, resolved.getResolveScope());
        }
      });
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:40,代码来源:GdkMethodUtil.java


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