本文整理汇总了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();
}
};
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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);
}
}
}
示例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();
}
};
}
示例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;
}
}
}
示例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());
}
示例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);
}
示例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;
}
}
示例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;
}
示例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)
};
}
示例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)
};
}
示例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))};
}
}
示例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)
};
}