當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。