本文整理汇总了Java中com.intellij.codeInspection.InspectionManager类的典型用法代码示例。如果您正苦于以下问题:Java InspectionManager类的具体用法?Java InspectionManager怎么用?Java InspectionManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
InspectionManager类属于com.intellij.codeInspection包,在下文中一共展示了InspectionManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createProblemDescriptorWithQuickFixes
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
private void createProblemDescriptorWithQuickFixes(PsiModifierListOwner owner,
InspectionManager manager,
Collection<ProblemDescriptor> problemDescriptors,
PsiElement element) {
if (element.isPhysical()) {
LocalQuickFix[] localQuickFixes = createQuickFixes(owner, isRemoveRedundantAnnotations());
ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
element,
MISSING_NULLABLE_NONNULL_ANNOTATION,
localQuickFixes,
GENERIC_ERROR_OR_WARNING,
true,
false);
problemDescriptors.add(problemDescriptor);
}
}
开发者ID:stylismo,项目名称:nullability-annotations-inspection,代码行数:17,代码来源:NullabilityAnnotationsInspection.java
示例2: analyzeFile
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@NotNull
private ProblemsHolder analyzeFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
DotEnvPsiElementsVisitor visitor = new DotEnvPsiElementsVisitor();
file.acceptChildren(visitor);
ProblemsHolder problemsHolder = new ProblemsHolder(manager, file, isOnTheFly);
Map<String, PsiElement> existingKeys = new HashMap<>();
Set<PsiElement> markedElements = new HashSet<>();
for(KeyValuePsiElement keyValue : visitor.getCollectedItems()) {
if(existingKeys.containsKey(keyValue.getKey())) {
problemsHolder.registerProblem(keyValue.getElement(), "Duplicate key");
PsiElement markedElement = existingKeys.get(keyValue.getKey());
if(!markedElements.contains(markedElement)) {
problemsHolder.registerProblem(markedElement, "Duplicate key");
markedElements.add(markedElement);
}
} else {
existingKeys.put(keyValue.getKey(), keyValue.getElement());
}
}
return problemsHolder;
}
示例3: showOfflineView
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@NotNull
public static InspectionResultsView showOfflineView(@NotNull Project project,
@NotNull Map<String, Map<String, Set<OfflineProblemDescriptor>>> resMap,
@NotNull InspectionProfile inspectionProfile,
@NotNull String title) {
final AnalysisScope scope = new AnalysisScope(project);
final InspectionManagerEx managerEx = (InspectionManagerEx)InspectionManager.getInstance(project);
final GlobalInspectionContextImpl context = managerEx.createNewGlobalContext(false);
context.setExternalProfile(inspectionProfile);
context.setCurrentScope(scope);
context.initializeTools(new ArrayList<Tools>(), new ArrayList<Tools>(), new ArrayList<Tools>());
final InspectionResultsView view = new InspectionResultsView(project, inspectionProfile, scope, context,
new OfflineInspectionRVContentProvider(resMap, project));
((RefManagerImpl)context.getRefManager()).startOfflineView();
view.update();
TreeUtil.selectFirstNode(view.getTree());
context.addView(view, title);
return view;
}
示例4: checkFile
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@Override
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
List<ProblemDescriptor> problems = Lists.newArrayList();
if (file.getFileType().equals(BuildoutCfgFileType.INSTANCE)) {
Visitor visitor = new Visitor();
file.accept(visitor);
for (BuildoutPartReference ref : visitor.getUnresolvedParts()) {
ProblemDescriptor d = manager
.createProblemDescriptor(ref.getElement(), ref.getRangeInElement(), PyBundle.message("buildout.unresolved.part.inspection.msg"),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false);
problems.add(d);
}
}
return problems.toArray(new ProblemDescriptor[problems.size()]);
}
示例5: checkDomFile
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
/**
* not intended to be overridden or called by implementors
*/
@Nullable
protected ProblemDescriptor[] checkDomFile(@NotNull final DomFileElement<T> domFileElement,
@NotNull final InspectionManager manager,
@SuppressWarnings("UnusedParameters") final boolean isOnTheFly) {
final DomElementAnnotationsManager annotationsManager = DomElementAnnotationsManager.getInstance(manager.getProject());
final List<DomElementProblemDescriptor> list = annotationsManager.checkFileElement(domFileElement, this, isOnTheFly);
if (list.isEmpty()) return ProblemDescriptor.EMPTY_ARRAY;
List<ProblemDescriptor> problems =
ContainerUtil.concat(list, new Function<DomElementProblemDescriptor, Collection<? extends ProblemDescriptor>>() {
@Override
public Collection<ProblemDescriptor> fun(final DomElementProblemDescriptor s) {
return annotationsManager.createProblemDescriptors(manager, s);
}
});
return problems.toArray(new ProblemDescriptor[problems.size()]);
}
示例6: testHighlightStatus_OtherInspections
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
public void testHighlightStatus_OtherInspections() throws Throwable {
myElement.setFileDescription(new DomFileDescription<DomElement>(DomElement.class, "a"));
final MyDomElementsInspection inspection = new MyDomElementsInspection() {
@Override
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager,
final boolean isOnTheFly) {
myAnnotationsManager.appendProblems(myElement, createHolder(), this.getClass());
return new ProblemDescriptor[0];
}
@Override
public void checkFileElement(final DomFileElement fileElement, final DomElementAnnotationHolder holder) {
}
};
HighlightDisplayKey.register(inspection.getShortName());
myInspectionProfile.setInspectionTools(new LocalInspectionToolWrapper(inspection));
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.ANNOTATORS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
myAnnotationsManager.appendProblems(myElement, createHolder(), inspection.getClass());
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
}
示例7: testHighlightStatus_OtherInspections2
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
public void testHighlightStatus_OtherInspections2() throws Throwable {
myElement.setFileDescription(new DomFileDescription<DomElement>(DomElement.class, "a"));
final MyDomElementsInspection inspection = new MyDomElementsInspection() {
@Override
public ProblemDescriptor[] checkFile(@NotNull final PsiFile file, @NotNull final InspectionManager manager,
final boolean isOnTheFly) {
myAnnotationsManager.appendProblems(myElement, createHolder(), this.getClass());
return new ProblemDescriptor[0];
}
@Override
public void checkFileElement(final DomFileElement fileElement, final DomElementAnnotationHolder holder) {
}
};
HighlightDisplayKey.register(inspection.getShortName());
LocalInspectionToolWrapper toolWrapper = new LocalInspectionToolWrapper(inspection);
myInspectionProfile.setInspectionTools(toolWrapper);
myInspectionProfile.setEnabled(toolWrapper, false);
myAnnotationsManager.appendProblems(myElement, createHolder(), MockAnnotatingDomInspection.class);
assertEquals(DomHighlightStatus.INSPECTIONS_FINISHED, myAnnotationsManager.getHighlightStatus(myElement));
}
示例8: checkPluginXml
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@Nullable
private ProblemDescriptor[] checkPluginXml(XmlFile xmlFile, InspectionManager manager, boolean isOnTheFly) {
final XmlDocument document = xmlFile.getDocument();
if (document == null) {
return null;
}
final XmlTag rootTag = document.getRootTag();
assert rootTag != null;
final RegistrationChecker checker = new RegistrationChecker(manager, xmlFile, isOnTheFly);
DescriptorUtil.processComponents(rootTag, checker);
DescriptorUtil.processActions(rootTag, checker);
return checker.getProblems();
}
示例9: checkNewExpression
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@Nullable
private static ProblemDescriptor checkNewExpression(PsiNewExpression expression, InspectionManager manager, boolean isOnTheFly) {
final Project project = manager.getProject();
final JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
final PsiClass jbColorClass = facade.findClass(JBColor.class.getName(), GlobalSearchScope.allScope(project));
final PsiType type = expression.getType();
if (type != null && jbColorClass != null) {
if (!facade.getResolveHelper().isAccessible(jbColorClass, expression, jbColorClass)) return null;
final PsiExpressionList arguments = expression.getArgumentList();
if (arguments != null) {
if ("java.awt.Color".equals(type.getCanonicalText())) {
final PsiElement parent = expression.getParent();
if (parent instanceof PsiExpressionList && parent.getParent() instanceof PsiNewExpression) {
final PsiType parentType = ((PsiNewExpression)parent.getParent()).getType();
if (parentType == null || JBColor.class.getName().equals(parentType.getCanonicalText())) return null;
}
return manager.createProblemDescriptor(expression, "Replace with JBColor", new ConvertToJBColorQuickFix(),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING, isOnTheFly);
}
}
}
return null;
}
示例10: checkClass
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@Override
public ProblemDescriptor[] checkClass(@NotNull PsiClass psiClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
final Project project = psiClass.getProject();
final PsiIdentifier nameIdentifier = psiClass.getNameIdentifier();
final Module module = ModuleUtilCore.findModuleForPsiElement(psiClass);
if (nameIdentifier == null || module == null || !PsiUtil.isInstantiable(psiClass)) return null;
final PsiClass base = JavaPsiFacade.getInstance(project).findClass(INSPECTION_PROFILE_ENTRY, GlobalSearchScope.allScope(project));
if (base == null || !psiClass.isInheritor(base, true) || isPathMethodsAreOverridden(psiClass)) return null;
final InspectionDescriptionInfo info = InspectionDescriptionInfo.create(module, psiClass);
if (!info.isValid() || info.hasDescriptionFile()) return null;
final PsiElement problemElement = getProblemElement(psiClass, info.getShortNameMethod());
final ProblemDescriptor problemDescriptor = manager
.createProblemDescriptor(problemElement == null ? nameIdentifier : problemElement,
"Inspection does not have a description", isOnTheFly,
new LocalQuickFix[]{new CreateHtmlDescriptionFix(info.getFilename(), module, DescriptionType.INSPECTION)},
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
return new ProblemDescriptor[]{problemDescriptor};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:InspectionDescriptionNotFoundInspection.java
示例11: doTest
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
public void doTest() {
myFixture.configureByFile(getTestName(false) + ".groovy");
final int offset = myFixture.getEditor().getCaretModel().getOffset();
final PsiElement atCaret = myFixture.getFile().findElementAt(offset);
final GrRangeExpression range = PsiTreeUtil.getParentOfType(atCaret, GrRangeExpression.class);
final GroovyRangeTypeCheckInspection inspection = new GroovyRangeTypeCheckInspection();
final GroovyFix fix = inspection.buildFix(range);
LocalQuickFix[] fixes = {fix};
final ProblemDescriptor descriptor = InspectionManager.getInstance(getProject()).createProblemDescriptor(range, "bla-bla", false, fixes, ProblemHighlightType.WEAK_WARNING);
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
@Override
public void run() {
fix.applyFix(myFixture.getProject(), descriptor);
PostprocessReformattingAspect.getInstance(getProject()).doPostponedFormatting();
}
});
myFixture.checkResultByFile(getTestName(false) + "_after.groovy");
}
示例12: checkClass
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@Override
public ProblemDescriptor[] checkClass( @NotNull PsiClass psiClass,
@NotNull InspectionManager manager,
boolean isOnTheFly )
{
PsiAnnotation mixinsAnnotation = getMixinsAnnotation( psiClass );
if( mixinsAnnotation == null )
{
return null;
}
if( psiClass.isInterface() )
{
return null;
}
String message = message( "mixins.annotation.declared.on.mixin.type.error.declared.on.class" );
RemoveInvalidMixinClassReferenceFix fix = new RemoveInvalidMixinClassReferenceFix( mixinsAnnotation );
ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( mixinsAnnotation, message, fix,
GENERIC_ERROR_OR_WARNING );
return new ProblemDescriptor[]{ problemDescriptor };
}
示例13: verifyAnnotationDeclaredCorrectly
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@Nullable
protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly( @NotNull PsiVariable psiVariable,
@NotNull PsiAnnotation structureAnnotation,
@NotNull InspectionManager manager )
{
StructureAnnotationDeclarationValidationResult annotationCheck =
validateStructureAnnotationDeclaration( psiVariable );
switch( annotationCheck )
{
case invalidInjectionType:
String message = message(
"injections.structure.annotation.declared.correctly.error.invalid.injection.type",
psiVariable.getType().getCanonicalText()
);
AbstractFix removeStructureAnnotationFix = createRemoveAnnotationFix( structureAnnotation );
ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(
structureAnnotation, message, removeStructureAnnotationFix, GENERIC_ERROR_OR_WARNING
);
return new ProblemDescriptor[]{ problemDescriptor };
}
return null;
}
示例14: checkFile
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@Override
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (PantsUtil.isBUILDFileName(file.getName()) && !PantsUtil.isPythonAvailable() && PantsUtil.isPantsProject(file.getProject())) {
LocalQuickFix[] fixes = new LocalQuickFix[]{new AddPythonPluginQuickFix()};
ProblemDescriptor descriptor = manager.createProblemDescriptor(
file.getNavigationElement(),
PantsBundle.message("pants.info.python.plugin.missing"),
isOnTheFly,
fixes,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING
);
return new ProblemDescriptor[]{descriptor};
}
return null;
}
示例15: checkFile
import com.intellij.codeInspection.InspectionManager; //导入依赖的package包/类
@Override
@Nullable
public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
if (PantsUtil.isBUILDFileName(file.getName()) && PantsUtil.isPythonAvailable() && PantsUtil.isPantsProject(file.getProject())) {
if (file.getFileType() != PythonFileType.INSTANCE) {
LocalQuickFix[] fixes = new LocalQuickFix[]{new TypeAssociationFix()};
ProblemDescriptor descriptor = manager.createProblemDescriptor(
file.getNavigationElement(),
PantsBundle.message("pants.info.mistreated.build.file"),
isOnTheFly,
fixes,
ProblemHighlightType.GENERIC_ERROR_OR_WARNING
);
return new ProblemDescriptor[]{descriptor};
}
}
return null;
}