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


Java RecursionManager.doPreventingRecursion方法代码示例

本文整理汇总了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;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GrReassignedLocalVarsChecker.java

示例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));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:27,代码来源:StubBasedPsiElementBase.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:21,代码来源:JSVariableBaseImpl.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:20,代码来源:VariableLookupItem.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:VariableLookupItem.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:InclusionProvider.java

示例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();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GradleResolverUtil.java

示例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();
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GrMapTypeFromNamedArgs.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:InclusionProvider.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:AstTransformContributor.java

示例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();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:AstTransformContributor.java

示例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;

    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:36,代码来源:GrClassImplUtil.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:13,代码来源:CSharpLambdaExpressionImpl.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:38,代码来源:StubTreeLoaderImpl.java

示例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;
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:16,代码来源:NullableNotNullManager.java


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