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


Java GlobalInspectionContext类代码示例

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


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


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