本文整理汇总了Java中com.intellij.openapi.util.RecursionManager.doPreventingRecursion方法的典型用法代码示例。如果您正苦于以下问题:Java RecursionManager.doPreventingRecursion方法的具体用法?Java RecursionManager.doPreventingRecursion怎么用?Java RecursionManager.doPreventingRecursion使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.util.RecursionManager
的用法示例。
在下文中一共展示了RecursionManager.doPreventingRecursion方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
});
}
示例2: 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));
}
示例3: 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;
}
示例4: 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);
}
示例5: 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);
}
示例6: 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);
}
示例7: 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();
}
});
}
示例8: inferTypePreventingRecursion
import com.intellij.openapi.util.RecursionManager; //导入方法依赖的package包/类
@Nullable
private static PsiType inferTypePreventingRecursion(final GrExpression expression) {
return RecursionManager.doPreventingRecursion(expression, false, new Computable<PsiType>() {
@Override
public PsiType compute() {
return expression.getType();
}
});
}
示例9: compute
import com.intellij.openapi.util.RecursionManager; //导入方法依赖的package包/类
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);
}
示例10: runContributorsForMethods
import com.intellij.openapi.util.RecursionManager; //导入方法依赖的package包/类
@NotNull
public static Collection<PsiMethod> runContributorsForMethods(@NotNull final GrTypeDefinition clazz) {
Collection<PsiMethod> result = RecursionManager.doPreventingRecursion(clazz, true, new Computable<Collection<PsiMethod>>() {
@Override
public Collection<PsiMethod> compute() {
Collection<PsiMethod> collector = new ArrayList<PsiMethod>();
for (final AstTransformContributor contributor : EP_NAME.getExtensions()) {
contributor.collectMethods(clazz, collector);
}
return collector;
}
});
return result == null ? Collections.<PsiMethod>emptyList() : result;
}
示例11: runContributorsForFields
import com.intellij.openapi.util.RecursionManager; //导入方法依赖的package包/类
@NotNull
public static List<GrField> runContributorsForFields(@NotNull final GrTypeDefinition clazz) {
List<GrField> fields = RecursionManager.doPreventingRecursion(clazz, true, new Computable<List<GrField>>() {
@Override
public List<GrField> compute() {
List<GrField> collector = new ArrayList<GrField>();
for (final AstTransformContributor contributor : EP_NAME.getExtensions()) {
contributor.collectFields(clazz, collector);
}
return collector;
}
});
return fields != null ? fields : Collections.<GrField>emptyList();
}
示例12: getImplementsFromDelegate
import com.intellij.openapi.util.RecursionManager; //导入方法依赖的package包/类
@Nullable
private static List<PsiClassType> getImplementsFromDelegate(@NotNull final GrTypeDefinition grType, final Set<PsiClass> visited) {
return RecursionManager.doPreventingRecursion(grType, true, new Computable<List<PsiClassType>>() {
@Override
public List<PsiClassType> compute() {
List<PsiClassType> result = new ArrayList<PsiClassType>();
final GrField[] fields = grType.getCodeFields();
for (GrField field : fields) {
final PsiAnnotation delegate = PsiImplUtil.getAnnotation(field, GroovyCommonClassNames.GROOVY_LANG_DELEGATE);
if (delegate == null) continue;
final boolean shouldImplement = shouldImplementDelegatedInterfaces(delegate);
if (!shouldImplement) continue;
final PsiType type = field.getDeclaredType();
if (!(type instanceof PsiClassType)) continue;
final PsiClass psiClass = ((PsiClassType)type).resolve();
if (psiClass == null) continue;
if (psiClass instanceof GrTypeDefinition) {
getImplementListsInner((GrTypeDefinition)psiClass, result, visited);
}
else {
result.addAll(Arrays.asList(psiClass.getImplementsListTypes()));
}
if (psiClass.isInterface()) {
result.add((PsiClassType)type);
}
}
return result;
}
});
}
示例13: toTypeRefForInference
import com.intellij.openapi.util.RecursionManager; //导入方法依赖的package包/类
@NotNull
@RequiredReadAction
public DotNetTypeRef toTypeRefForInference()
{
// recursion when child lambda reference to parameter from parent lambda
DotNetTypeRef returnType = RecursionManager.doPreventingRecursion("C# lambda return type", false, this::findPossibleReturnTypeRef);
if(returnType == null)
{
returnType = DotNetTypeRef.ERROR_TYPE;
}
return new CSharpLambdaTypeRef(this, null, getParameterInfos(true), returnType);
}
示例14: readOrBuild
import com.intellij.openapi.util.RecursionManager; //导入方法依赖的package包/类
@Override
@Nullable
public ObjectStubTree readOrBuild(Project project, final VirtualFile vFile, @Nullable PsiFile psiFile) {
final ObjectStubTree fromIndices = readFromVFile(project, vFile);
if (fromIndices != null) {
return fromIndices;
}
try {
byte[] content = vFile.contentsToByteArray();
vFile.setPreloadedContentHint(content);
final FileContent fc;
try {
fc = new FileContentImpl(vFile, content);
fc.putUserData(IndexingDataKeys.PROJECT, project);
if (psiFile != null && !vFile.getFileType().isBinary()) {
fc.putUserData(IndexingDataKeys.FILE_TEXT_CONTENT_KEY, psiFile.getViewProvider().getContents());
// but don't reuse psiFile itself to avoid loading its contents. If we load AST, the stub will be thrown out anyway.
}
Stub element = RecursionManager.doPreventingRecursion(vFile, false, () -> StubTreeBuilder.buildStubTree(fc));
if (element instanceof PsiFileStub) {
StubTree tree = new StubTree((PsiFileStub)element);
tree.setDebugInfo("created from file content");
return tree;
}
}
finally {
vFile.setPreloadedContentHint(null);
}
}
catch (IOException e) {
LOG.info(e); // content can be not cached yet, and the file can be deleted on disk already, without refresh
}
return null;
}
示例15: takeAnnotationFromSuperParameters
import com.intellij.openapi.util.RecursionManager; //导入方法依赖的package包/类
private PsiAnnotation takeAnnotationFromSuperParameters(@NotNull PsiParameter owner, final List<PsiParameter> superOwners)
{
return RecursionManager.doPreventingRecursion(owner, true, () ->
{
for(PsiParameter superOwner : superOwners)
{
PsiAnnotation anno = findNullabilityAnnotationWithDefault(superOwner, false, false);
if(anno != null)
{
return anno;
}
}
return null;
});
}