• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GlobalInspectionContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: createReferenceProcessor

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
private static PsiReferenceProcessor createReferenceProcessor(@NotNull final List<UsagesProcessor> processors,
                                                              final GlobalInspectionContext context) {
  return new PsiReferenceProcessor() {
    @Override
    public boolean execute(PsiReference reference) {
      AnalysisScope scope = context.getRefManager().getScope();
      if (scope != null && scope.contains(reference.getElement()) && reference.getElement().getLanguage() == StdLanguages.JAVA ||
          PsiTreeUtil.getParentOfType(reference.getElement(), PsiDocComment.class) != null) {
        return true;
      }

      synchronized (processors) {
        UsagesProcessor[] processorsArrayed = processors.toArray(new UsagesProcessor[processors.size()]);
        for (UsagesProcessor processor : processorsArrayed) {
          if (!processor.process(reference)) {
            processors.remove(processor);
          }
        }
      }

      return !processors.isEmpty();
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:GlobalJavaInspectionContextImpl.java


示例2: RefManagerImpl

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
public RefManagerImpl(@NotNull Project project, @Nullable AnalysisScope scope, @NotNull GlobalInspectionContext context) {
  myProject = project;
  myScope = scope;
  myContext = context;
  myPsiManager = PsiManager.getInstance(project);
  myRefProject = new RefProjectImpl(this);
  for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
    final RefManagerExtension extension = factory.createRefManagerExtension(this);
    if (extension != null) {
      myExtensions.put(extension.getID(), extension);
      myLanguageExtensions.put(extension.getLanguage(), extension);
    }
  }
  if (scope != null) {
    for (Module module : ModuleManager.getInstance(getProject()).getModules()) {
      getRefModule(module);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:RefManagerImpl.java


示例3: RefManagerImpl

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
public RefManagerImpl(@NotNull Project project, AnalysisScope scope, @NotNull GlobalInspectionContext context) {
  myDeclarationsFound = false;
  myProject = project;
  myScope = scope;
  myContext = context;
  myPsiManager = PsiManager.getInstance(project);
  myRefProject = new RefProjectImpl(this);
  myProjectIterator = new ProjectIterator();
  for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
    final RefManagerExtension extension = factory.createRefManagerExtension(this);
    if (extension != null) {
      myExtensions.put(extension.getID(), extension);
      myLanguageExtensions.put(extension.getLanguage(), extension);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:RefManagerImpl.java


示例4: run

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
protected void run() {
    InspectionManager inspectionManager = InspectionManager.getInstance(project);
    GlobalInspectionContext context = inspectionManager.createNewGlobalContext(false);
    InspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(inspectionTool);
    List<ProblemDescriptor> problemDescriptors;
    try {
        problemDescriptors = InspectionEngine.runInspectionOnFile(psiFile, toolWrapper, context);
    } catch (IndexNotReadyException exception) {
        return;
    }
    for (ProblemDescriptor problemDescriptor : problemDescriptors) {
        QuickFix[] fixes = problemDescriptor.getFixes();
        if (fixes != null) {
            writeQuickFixes(problemDescriptor, fixes);
        }
    }
}
 
开发者ID:dubreuia,项目名称:intellij-plugin-save-actions,代码行数:19,代码来源:InspectionProcessor.java


示例5: RefManagerImpl

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
public RefManagerImpl(@Nonnull Project project, AnalysisScope scope, @Nonnull GlobalInspectionContext context) {
  myDeclarationsFound = false;
  myProject = project;
  myScope = scope;
  myContext = context;
  myPsiManager = PsiManager.getInstance(project);
  myRefProject = new RefProjectImpl(this);
  myProjectIterator = new ProjectIterator();
  for (InspectionExtensionsFactory factory : Extensions.getExtensions(InspectionExtensionsFactory.EP_NAME)) {
    final RefManagerExtension extension = factory.createRefManagerExtension(this);
    if (extension != null) {
      myExtensions.put(extension.getID(), extension);
      myLanguageExtensions.put(extension.getLanguage(), extension);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo,代码行数:17,代码来源:RefManagerImpl.java


示例6: createReferenceProcessor

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
private static PsiReferenceProcessor createReferenceProcessor(@NotNull final List<UsagesProcessor> processors,
                                                              final GlobalInspectionContext context) {
  return new PsiReferenceProcessor() {
    @Override
    public boolean execute(PsiReference reference) {
      AnalysisScope scope = context.getRefManager().getScope();
      if (scope.contains(reference.getElement()) && reference.getElement().getLanguage() == JavaLanguage.INSTANCE ||
          PsiTreeUtil.getParentOfType(reference.getElement(), PsiDocComment.class) != null) {
        return true;
      }

      synchronized (processors) {
        UsagesProcessor[] processorsArrayed = processors.toArray(new UsagesProcessor[processors.size()]);
        for (UsagesProcessor processor : processorsArrayed) {
          if (!processor.process(reference)) {
            processors.remove(processor);
          }
        }
      }

      return !processors.isEmpty();
    }
  };
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:GlobalJavaInspectionContextImpl.java


示例7: performPreRunActivities

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
public void performPreRunActivities(@NotNull final List<Tools> globalTools,
                                    @NotNull final List<Tools> localTools,
                                    @NotNull final GlobalInspectionContext context) {
  getEntryPointsManager(context.getRefManager()).resolveEntryPoints(context.getRefManager());
  // UnusedDeclarationInspection should run first
  for (int i = 0; i < globalTools.size(); i++) {
    InspectionToolWrapper toolWrapper = globalTools.get(i).getTool();
    if (UnusedDeclarationInspection.SHORT_NAME.equals(toolWrapper.getShortName())) {
      Collections.swap(globalTools, i, 0);
      break;
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GlobalJavaInspectionContextImpl.java


示例8: performPostRunActivities

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
public void performPostRunActivities(@NotNull List<InspectionToolWrapper> needRepeatSearchRequest, @NotNull final GlobalInspectionContext context) {
  JobDescriptor progress = context.getStdJobDescriptors().FIND_EXTERNAL_USAGES;
  progress.setTotalAmount(getRequestCount());

  do {
    processSearchRequests(context);
    InspectionToolWrapper[] requestors = needRepeatSearchRequest.toArray(new InspectionToolWrapper[needRepeatSearchRequest.size()]);
    InspectionManager inspectionManager = InspectionManager.getInstance(context.getProject());
    for (InspectionToolWrapper toolWrapper : requestors) {
      boolean result = false;
      if (toolWrapper instanceof GlobalInspectionToolWrapper) {
        InspectionToolPresentation presentation = ((GlobalInspectionContextImpl)context).getPresentation(toolWrapper);
        result = ((GlobalInspectionToolWrapper)toolWrapper).getTool().queryExternalUsagesRequests(inspectionManager, context, presentation);
      }
      if (!result) {
        needRepeatSearchRequest.remove(toolWrapper);
      }
    }
    int oldSearchRequestCount = progress.getTotalAmount();
    int oldDoneAmount = progress.getDoneAmount();
    int totalAmount = oldSearchRequestCount + getRequestCount();
    progress.setTotalAmount(totalAmount);
    progress.setDoneAmount(oldDoneAmount);
  }
  while (!needRepeatSearchRequest.isEmpty());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:GlobalJavaInspectionContextImpl.java


示例9: initialize

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
public void initialize(@NotNull GlobalInspectionContext context) {
  super.initialize(context);
  RefManagerImpl refManager = (RefManagerImpl)context.getRefManager();
  final RefGraphAnnotator annotator = getTool().getAnnotator(refManager);
  if (annotator != null) {
    refManager.registerGraphAnnotator(annotator);
  }
  getTool().initialize(context);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:GlobalInspectionToolWrapper.java


示例10: getJobDescriptors

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
@NotNull
public JobDescriptor[] getJobDescriptors(@NotNull GlobalInspectionContext context) {
  final JobDescriptor[] additionalJobs = getTool().getAdditionalJobs();
  if (additionalJobs == null) {
    return getTool().isGraphNeeded() ? context.getStdJobDescriptors().BUILD_GRAPH_ONLY : JobDescriptor.EMPTY_ARRAY;
  }
  else {
    return getTool().isGraphNeeded() ? ArrayUtil.append(additionalJobs, context.getStdJobDescriptors().BUILD_GRAPH) : additionalJobs;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:GlobalInspectionToolWrapper.java


示例11: retrieveRefElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
public static RefElement retrieveRefElement(@NotNull PsiElement element, @NotNull GlobalInspectionContext globalContext) {
  PsiFile elementFile = element.getContainingFile();
  RefElement refElement = globalContext.getRefManager().getReference(elementFile);
  if (refElement == null) {
    PsiElement context = InjectedLanguageManager.getInstance(elementFile.getProject()).getInjectionHost(elementFile);
    if (context != null) refElement = globalContext.getRefManager().getReference(context.getContainingFile());
  }
  return refElement;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:GlobalInspectionContextUtil.java


示例12: checkElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
  @NotNull RefEntity refEntity,
  @NotNull AnalysisScope analysisScope,
  @NotNull InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefModule)) {
    return null;
  }
  final List<RefEntity> children = refEntity.getChildren();
  if (children == null) {
    return null;
  }
  int numClasses = 0;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      numClasses++;
    }
  }
  if (numClasses <= limit) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message(
    "module.with.too.many.classes.problem.descriptor",
    refEntity.getName(), Integer.valueOf(numClasses),
    Integer.valueOf(limit));
  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:ModuleWithTooManyClassesInspection.java


示例13: checkElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope, @NotNull InspectionManager inspectionManager,
                                              @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefModule)) {
    return null;
  }
  final RefModule refModule = (RefModule)refEntity;
  final List<RefEntity> children = refModule.getChildren();
  if (children == null) {
    return null;
  }
  int numClasses = 0;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      numClasses++;
    }
  }
  if (numClasses >= limit || numClasses == 0) {
    return null;
  }
  final Project project = globalInspectionContext.getProject();
  final Module[] modules = ModuleManager.getInstance(project).getModules();
  if (modules.length == 1) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message("module.with.too.few.classes.problem.descriptor",
                                                             refModule.getName(), Integer.valueOf(numClasses), Integer.valueOf(limit));
  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:ModuleWithTooFewClassesInspection.java


示例14: checkElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Nullable
@Override
public CommonProblemDescriptor[] checkElement(@NotNull RefEntity refEntity,
                                              @NotNull AnalysisScope scope,
                                              @NotNull InspectionManager manager,
                                              @NotNull GlobalInspectionContext globalContext) {
  if (!(refEntity instanceof RefPackage)) {
    return null;
  }
  final RefPackage refPackage = (RefPackage)refEntity;
  final String packageName = refPackage.getQualifiedName();
  final Project project = globalContext.getProject();
  final PsiPackage aPackage = JavaPsiFacade.getInstance(project).findPackage(packageName);
  if (hasPackageInfoFile(aPackage)) {
    return null;
  }
  final List<RefEntity> children = refPackage.getChildren();
  boolean hasClasses = false;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      hasClasses = true;
      break;
    }
  }
  if (!hasClasses) {
    return null;
  }
  if (PsiUtil.isLanguageLevel5OrHigher(aPackage)) {
    return new CommonProblemDescriptor[] {
      manager.createProblemDescriptor(InspectionGadgetsBundle.message("missing.package.info.problem.descriptor", packageName))};
  }
  else {
    return new CommonProblemDescriptor[] {
      manager.createProblemDescriptor(InspectionGadgetsBundle.message("missing.package.html.problem.descriptor", packageName))};
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:MissingPackageInfoInspectionBase.java


示例15: checkElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
  @NotNull RefEntity refEntity,
  @NotNull AnalysisScope analysisScope,
  @NotNull InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefPackage)) {
    return null;
  }
  final List<RefEntity> children = refEntity.getChildren();
  if (children == null) {
    return null;
  }
  int numClasses = 0;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      numClasses++;
    }
  }
  if (numClasses <= limit) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message(
    "package.with.too.many.classes.problem.descriptor",
    refEntity.getQualifiedName(), Integer.valueOf(numClasses),
    Integer.valueOf(limit));
  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:32,代码来源:PackageWithTooManyClassesInspection.java


示例16: checkElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
  @NotNull RefEntity refEntity, @NotNull AnalysisScope analysisScope,
  @NotNull InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefPackage)) {
    return null;
  }
  final List<RefEntity> children = refEntity.getChildren();
  if (children == null) {
    return null;
  }
  final Set<RefModule> modules = new HashSet<RefModule>();
  for (RefEntity child : children) {
    if (!(child instanceof RefClass)) {
      continue;
    }
    final RefClass refClass = (RefClass)child;
    final RefModule module = refClass.getModule();
    modules.add(module);
  }
  if (modules.size() <= 1) {
    return null;
  }
  final String errorString =
    InspectionGadgetsBundle.message(
      "package.in.multiple.modules.problem.descriptor",
      refEntity.getQualifiedName());

  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)};
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:PackageInMultipleModulesInspection.java


示例17: checkElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
  @NotNull RefEntity refEntity,
  @NotNull AnalysisScope analysisScope,
  @NotNull InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefPackage)) {
    return null;
  }
  final List<RefEntity> children = refEntity.getChildren();
  if (children == null) {
    return null;
  }
  int numClasses = 0;
  boolean subpackage = false;
  for (RefEntity child : children) {
    if (child instanceof RefClass) {
      numClasses++;
    }
    else if (child instanceof RefPackage) {
      subpackage = true;
    }
  }
  if (numClasses >= limit || (numClasses == 0 && subpackage)) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message(
    "package.with.too.few.classes.problem.descriptor",
    refEntity.getQualifiedName(), Integer.valueOf(numClasses),
    Integer.valueOf(limit));
  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:PackageWithTooFewClassesInspection.java


示例18: checkElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
  @NotNull RefEntity refEntity,
  @NotNull AnalysisScope analysisScope,
  @NotNull InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefClass)) {
    return null;
  }
  final RefClass refClass = (RefClass)refEntity;
  final PsiClass aClass = refClass.getElement();
  if (ClassUtils.isInnerClass(aClass)) {
    return null;
  }
  final Set<RefClass> dependents =
    DependencyUtils.calculateDependentsForClass(refClass);
  final int numDependents = dependents.size();
  if (numDependents <= limit) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message(
    "class.with.too.many.dependents.problem.descriptor",
    refEntity.getName(), numDependents, limit);

  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ClassWithTooManyDependentsInspection.java


示例19: runInspection

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的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


示例20: checkElement

import com.intellij.codeInspection.GlobalInspectionContext; //导入依赖的package包/类
@Override
@Nullable
public CommonProblemDescriptor[] checkElement(
  @NotNull RefEntity refEntity,
  @NotNull AnalysisScope analysisScope,
  @NotNull InspectionManager inspectionManager,
  @NotNull GlobalInspectionContext globalInspectionContext) {
  if (!(refEntity instanceof RefClass)) {
    return null;
  }
  final RefClass refClass = (RefClass)refEntity;
  final PsiClass aClass = refClass.getElement();
  if (ClassUtils.isInnerClass(aClass)) {
    return null;
  }

  final Set<RefClass> dependencies =
    DependencyUtils.calculateTransitiveDependentsForClass(refClass);
  final int numDependents = dependencies.size();
  if (numDependents <= limit) {
    return null;
  }
  final String errorString = InspectionGadgetsBundle.message(
    "class.with.too.many.transitive.dependents.problem.descriptor",
    refEntity.getName(), numDependents, limit);
  return new CommonProblemDescriptor[]{
    inspectionManager.createProblemDescriptor(errorString)
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:ClassWithTooManyTransitiveDependentsInspection.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ComponentObject类代码示例发布时间:2022-05-23
下一篇:
Java ILOAD类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap