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


Java RefJavaVisitor类代码示例

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


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

示例1: runInspection

import com.intellij.codeInspection.reference.RefJavaVisitor; //导入依赖的package包/类
@Override
public void runInspection(
  @NotNull AnalysisScope scope,
  @NotNull final InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext,
  @NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
  final RefManager refManager = globalInspectionContext.getRefManager();
  refManager.iterate(new RefJavaVisitor() {

    @Override
    public void visitClass(@NotNull RefClass refClass) {
      super.visitClass(refClass);
      if (refClass.getOwner() instanceof RefClass) {
        return;
      }
      final Set<RefClass> dependencies =
        DependencyUtils.calculateDependenciesForClass(refClass);
      final int numDependencies = dependencies.size();
      if (numDependencies <= limit) {
        return;
      }
      final String errorString = InspectionGadgetsBundle.message(
        "class.with.too.many.dependencies.problem.descriptor",
        refClass.getName(), numDependencies, limit);
      final CommonProblemDescriptor[] descriptors = {
        inspectionManager.createProblemDescriptor(errorString)};
      problemDescriptionsProcessor.addProblemElement(refClass, descriptors);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:ClassWithTooManyDependenciesInspection.java

示例2: runInspection

import com.intellij.codeInspection.reference.RefJavaVisitor; //导入依赖的package包/类
@Override
public void runInspection(
  @NotNull AnalysisScope scope,
  @NotNull final InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext,
  @NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
  final RefManager refManager = globalInspectionContext.getRefManager();
  refManager.iterate(new RefJavaVisitor() {

    @Override
    public void visitClass(@NotNull RefClass refClass) {
      super.visitClass(refClass);
      if (!(refClass.getOwner() instanceof RefFile)) {
        return;
      }
      final Set<RefClass> dependencies =
        DependencyUtils.calculateDependenciesForClass(refClass);
      final int numDependencies = dependencies.size();
      if (numDependencies <= limit) {
        return;
      }
      final String errorString = InspectionGadgetsBundle.message(
        "class.with.too.many.dependencies.problem.descriptor",
        refClass.getName(), numDependencies, limit);
      final CommonProblemDescriptor[] descriptors = {
        inspectionManager.createProblemDescriptor(errorString)};
      problemDescriptionsProcessor.addProblemElement(refClass, descriptors);
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:ClassWithTooManyDependenciesInspection.java

示例3: updateContent

import com.intellij.codeInspection.reference.RefJavaVisitor; //导入依赖的package包/类
@Override
public void updateContent()
{
	getTool().checkForReachables(getContext());
	myPackageContents.clear();
	getContext().getRefManager().iterate(new RefJavaVisitor()
	{
		@Override
		public void visitElement(@NotNull RefEntity refEntity)
		{
			if(!(refEntity instanceof RefJavaElement))
			{
				return;//dead code doesn't work with refModule | refPackage
			}
			RefJavaElement refElement = (RefJavaElement) refEntity;
			if(!(getContext().getUIOptions().FILTER_RESOLVED_ITEMS && getIgnoredRefElements().contains(refElement)
			) && refElement.isValid() && getFilter().accepts(refElement))
			{
				String packageName = RefJavaUtil.getInstance().getPackageName(refEntity);
				Set<RefEntity> content = myPackageContents.get(packageName);
				if(content == null)
				{
					content = new HashSet<RefEntity>();
					myPackageContents.put(packageName, content);
				}
				content.add(refEntity);
			}
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:UnusedDeclarationPresentation.java

示例4: runInspection

import com.intellij.codeInspection.reference.RefJavaVisitor; //导入依赖的package包/类
@Override
public void runInspection(
  AnalysisScope scope,
  final InspectionManager inspectionManager,
  GlobalInspectionContext globalInspectionContext,
  final ProblemDescriptionsProcessor problemDescriptionsProcessor) {
  final RefManager refManager = globalInspectionContext.getRefManager();
  refManager.iterate(new RefJavaVisitor() {

    @Override
    public void visitClass(@NotNull RefClass refClass) {
      super.visitClass(refClass);
      if (!(refClass.getOwner() instanceof RefFile)) {
        return;
      }
      final Set<RefClass> dependencies =
        DependencyUtils.calculateDependenciesForClass(refClass);
      final int numDependencies = dependencies.size();
      if (numDependencies <= limit) {
        return;
      }
      final String errorString = InspectionGadgetsBundle.message(
        "class.with.too.many.dependencies.problem.descriptor",
        refClass.getName(), numDependencies, limit);
      final CommonProblemDescriptor[] descriptors = {
        inspectionManager.createProblemDescriptor(errorString)};
      problemDescriptionsProcessor.addProblemElement(refClass, descriptors);
    }
  });
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:ClassWithTooManyDependenciesInspection.java

示例5: queryExternalUsagesRequests

import com.intellij.codeInspection.reference.RefJavaVisitor; //导入依赖的package包/类
@Override
public boolean queryExternalUsagesRequests(@NotNull final InspectionManager manager,
		@NotNull final GlobalInspectionContext globalContext,
		@NotNull final ProblemDescriptionsProcessor problemDescriptionsProcessor)
{
	globalContext.getRefManager().iterate(new RefJavaVisitor()
	{
		@Override
		public void visitElement(@NotNull RefEntity refEntity)
		{
			if(refEntity instanceof RefMethod)
			{
				final SmartPsiElementPointer<PsiClass> classPointer = refEntity.getUserData(MARKER);
				if(classPointer != null)
				{
					final Ref<PsiClass> ref = Ref.create(classPointer.getElement());
					final GlobalJavaInspectionContext globalJavaContext = globalContext.getExtension(GlobalJavaInspectionContext.CONTEXT);
					globalJavaContext.enqueueMethodUsagesProcessor((RefMethod) refEntity, new GlobalJavaInspectionContext.UsagesProcessor()
					{
						@Override
						public boolean process(PsiReference reference)
						{
							final PsiClass containingClass = ClassUtils.getContainingClass(reference.getElement());
							if(problemDescriptionsProcessor.getDescriptions(refEntity) != null)
							{
								if(containingClass != ref.get())
								{
									problemDescriptionsProcessor.ignoreElement(refEntity);
									return false;
								}
								return true;
							}
							else
							{
								final PsiIdentifier identifier = ((PsiMethod) ((RefMethod) refEntity).getElement()).getNameIdentifier();
								final ProblemDescriptor problemDescriptor = createProblemDescriptor(manager, identifier, containingClass);
								problemDescriptionsProcessor.addProblemElement(refEntity, problemDescriptor);
								ref.set(containingClass);
								return true;
							}
						}
					});
				}
			}
		}
	});

	return false;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:50,代码来源:StaticMethodOnlyUsedInOneClassInspection.java


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