Java Code Examples for com.intellij.codeInspection.InspectionManager#createProblemDescriptor()
The following examples show how to use
com.intellij.codeInspection.InspectionManager#createProblemDescriptor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: NamespacePrefixFromFileName.java From intellij-xquery with Apache License 2.0 | 6 votes |
@Override public ProblemDescriptor[] checkFile(PsiFile file, InspectionManager manager, boolean isOnTheFly) { if (!(file instanceof XQueryFile)) { return null; } final XQueryModuleDecl moduleDeclaration = ((XQueryFile) file).getModuleDeclaration(); if (moduleDeclaration != null && moduleDeclaration.getNamespacePrefix() != null && moduleDeclaration.getURILiteral() != null && !namespacePrefixIsDerivedFromFileName(moduleDeclaration)) { ProblemDescriptor[] problemDescriptors = new ProblemDescriptor[1]; problemDescriptors[0] = manager.createProblemDescriptor(moduleDeclaration.getNamespacePrefix(), "Namespace prefix should be derived from file name part in URI", (LocalQuickFix) null, GENERIC_ERROR_OR_WARNING, true); return problemDescriptors; } else { return null; } }
Example 2
Source File: InvalidVersionInspection.java From intellij-xquery with Apache License 2.0 | 6 votes |
@Override public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { if (!(file instanceof XQueryFile)) { return null; } XQueryVersionDecl versionDecl = PsiTreeUtil.findChildOfType(file, XQueryVersionDecl.class); XQueryVersion version = versionDecl != null ? versionDecl.getVersion() : null; if (version != null) { String versionString = version.getVersionString(); XQueryLanguageVersion languageVersion = XQueryLanguageVersion.valueFor(versionString); if (languageVersion == null) { ProblemDescriptor problem = manager.createProblemDescriptor(versionDecl.getVersion(), getDescription(versionString), (LocalQuickFix) null, WEAK_WARNING, true); return new ProblemDescriptor[]{problem}; } } return null; }
Example 3
Source File: MixinsAnnotationDeclaredOnMixinType.java From attic-polygene-java with Apache License 2.0 | 6 votes |
@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 }; }
Example 4
Source File: StructureAnnotationDeclaredCorrectlyInspection.java From attic-polygene-java with Apache License 2.0 | 6 votes |
@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; }
Example 5
Source File: BuildFileTypeInspection.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@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; }
Example 6
Source File: PythonPluginInspection.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@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; }
Example 7
Source File: PythonFacetInspection.java From intellij-pants-plugin with Apache License 2.0 | 6 votes |
@Override @Nullable public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) { if (shouldAddPythonSdk(file)) { LocalQuickFix[] fixes = new LocalQuickFix[]{new AddPythonFacetQuickFix()}; ProblemDescriptor descriptor = manager.createProblemDescriptor( file.getNavigationElement(), PantsBundle.message("pants.info.python.facet.missing"), isOnTheFly, fixes, ProblemHighlightType.GENERIC_ERROR_OR_WARNING ); return new ProblemDescriptor[]{descriptor}; } return null; }
Example 8
Source File: AbstractInjectionAnnotationDeclarationOnFieldInspection.java From attic-polygene-java with Apache License 2.0 | 5 votes |
@Override public final ProblemDescriptor[] checkField( @NotNull PsiField field, @NotNull InspectionManager manager, boolean isOnTheFly ) { PsiAnnotation annotationToCheck = getAnnotationToCheck( field ); if( annotationToCheck == null ) { return null; } PsiModifierList modifierList = field.getModifierList(); if( modifierList != null ) { if( modifierList.hasModifierProperty( com.intellij.psi.PsiModifier.STATIC ) ) { String message = getInjectionAnnotationValidDeclarationMessage(); AbstractFix removeAnnotationFix = createRemoveAnnotationFix( annotationToCheck ); ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( annotationToCheck, message, removeAnnotationFix, com.intellij.codeInspection.ProblemHighlightType.GENERIC_ERROR_OR_WARNING ); return new ProblemDescriptor[]{ problemDescriptor }; } } return verifyAnnotationDeclaredCorrectly( field, annotationToCheck, manager ); }
Example 9
Source File: DefaultFunctionNamespaceSameAsModuleNamespace.java From intellij-xquery with Apache License 2.0 | 5 votes |
private ProblemDescriptor[] createProblemDescriptor(InspectionManager manager, XQueryURILiteral defaultNamespaceFunctionDeclarationURILiteral) { ProblemDescriptor[] problemDescriptors = new ProblemDescriptor[1]; problemDescriptors[0] = manager.createProblemDescriptor(defaultNamespaceFunctionDeclarationURILiteral, "Default function namespace should be same as module namespace", (LocalQuickFix) null, GENERIC_ERROR_OR_WARNING, true); return problemDescriptors; }
Example 10
Source File: UnusedVariableInspection.java From intellij-xquery with Apache License 2.0 | 5 votes |
private ProblemDescriptor[] buildProblemDescriptionsForUnusedVariables(InspectionManager manager, List<XQueryVarName> unusedVariables) { ProblemDescriptor[] problemDescriptors = new ProblemDescriptor[unusedVariables.size()]; int ind = 0; for (XQueryVarName varName : unusedVariables) { final ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(varName, getDescription(varName), (LocalQuickFix) null, LIKE_UNUSED_SYMBOL, true); problemDescriptors[ind++] = problemDescriptor; } return problemDescriptors; }
Example 11
Source File: UppercaseStatePropInspection.java From litho with Apache License 2.0 | 5 votes |
private static ProblemDescriptor createWarning( PsiElement element, InspectionManager manager, boolean isOnTheFly) { return manager.createProblemDescriptor( element, "Should not be capitalized: " + element.getText(), true /* show tooltip */, ProblemHighlightType.ERROR, isOnTheFly); }
Example 12
Source File: MixinImplementsMixinType.java From attic-polygene-java with Apache License 2.0 | 5 votes |
private ProblemDescriptor createProblemDescriptor( @NotNull InspectionManager manager, @NotNull PsiAnnotationMemberValue mixinAnnotationValue, @NotNull PsiJavaCodeReferenceElement mixinClassReference, @NotNull String message ) { RemoveInvalidMixinClassReferenceFix fix = new RemoveInvalidMixinClassReferenceFix( mixinAnnotationValue, mixinClassReference ); return manager.createProblemDescriptor( mixinAnnotationValue, message, fix, GENERIC_ERROR_OR_WARNING ); }
Example 13
Source File: AppliesToAnnotationDeclaredCorrectlyInspection.java From attic-polygene-java with Apache License 2.0 | 5 votes |
@NotNull private ProblemDescriptor createRemoveAppliesToFilterProblemDescriptor( @NotNull InspectionManager manager, @NotNull String problemMessage, @NotNull PsiAnnotation appliesToAnnotation ) { RemoveAppliesToFilterAnnotationFix fix = new RemoveAppliesToFilterAnnotationFix( appliesToAnnotation ); return manager.createProblemDescriptor( appliesToAnnotation, problemMessage, fix, GENERIC_ERROR_OR_WARNING ); }
Example 14
Source File: LoadStatementAnnotator.java From intellij with Apache License 2.0 | 5 votes |
private void validateImportTarget(@Nullable StringLiteral target) { if (target == null) { return; } String targetString = target.getStringContents(); if (targetString == null || targetString.startsWith(":") || targetString.startsWith("//") || targetString.startsWith("@") || targetString.length() < 2) { return; } if (targetString.startsWith("/")) { Annotation annotation = markWarning( target, "Deprecated load syntax; loaded Starlark module should by in label format."); InspectionManager inspectionManager = InspectionManager.getInstance(target.getProject()); ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor( target, annotation.getMessage(), DeprecatedLoadQuickFix.INSTANCE, ProblemHighlightType.LIKE_DEPRECATED, true); annotation.registerFix(DeprecatedLoadQuickFix.INSTANCE, null, null, descriptor); return; } markError(target, "Invalid load syntax: missing Starlark module."); }
Example 15
Source File: ServiceAnnotationDeclaredCorrectlyInspection.java From attic-polygene-java with Apache License 2.0 | 4 votes |
@Nullable protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly( @NotNull PsiVariable psiVariable, @NotNull PsiAnnotation serviceAnnotation, @NotNull InspectionManager manager ) { ServiceAnnotationDeclarationValidationResult annotationCheck = isValidServiceAnnotationDeclaration( psiVariable ); String message = null; LocalQuickFix fix = null; switch( annotationCheck ) { case invalidTypeIsInjectedViaStructureAnnotation: if( getStructureAnnotation( psiVariable ) == null ) { fix = new ReplaceWithStructureAnnotation( message( "injections.service.annotation.declared.correctly.fix.replace.with.structure.annotation" ), serviceAnnotation ); } message = message( "injections.service.annotation.declared.correctly.error.type.is.injected.by.structure", psiVariable.getType().getCanonicalText() ); break; } // If it's not an error, return null if( message == null ) { return null; } // Default behavior to remove @Service annotation if( fix == null ) { fix = createRemoveAnnotationFix( serviceAnnotation ); } ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( serviceAnnotation, message, fix, GENERIC_ERROR_OR_WARNING ); return new ProblemDescriptor[]{ problemDescriptor }; }
Example 16
Source File: InvocationAnnotationDeclaredCorrectlyInspection.java From attic-polygene-java with Apache License 2.0 | 4 votes |
@Nullable protected final ProblemDescriptor[] verifyAnnotationDeclaredCorrectly( @NotNull PsiVariable psiVariable, @NotNull PsiAnnotation invocationAnnotation, @NotNull InspectionManager manager ) { LocalQuickFix fix = null; String message = null; String variableTypeQualifiedName = psiVariable.getType().getCanonicalText(); InvocationAnnotationDeclarationValidationResult validationResult = isValidInvocationAnnotationDeclaration( psiVariable ); switch( validationResult ) { case invalidTypeIsInjectedViaStructureAnnotation: if( getStructureAnnotation( psiVariable ) == null ) { fix = new ReplaceWithStructureAnnotation( message( "injections.invocation.annotation.declared.correctly.fix.replace.with.structure.annotation" ), invocationAnnotation ); } message = message( "injections.invocation.annotation.declared.correctly.error.type.is.injected.by.structure", variableTypeQualifiedName ); break; case invalidType: message = message( "injections.invocation.annotation.declared.correctly.error.type.is.not.injectable", variableTypeQualifiedName ); break; } // If it's not an error, return null if( message == null ) { return null; } // If Fix not defined, by default we remove it. if( fix == null ) { fix = createRemoveAnnotationFix( invocationAnnotation ); } ProblemDescriptor problemDescriptor = manager.createProblemDescriptor( invocationAnnotation, message, fix, GENERIC_ERROR_OR_WARNING ); return new ProblemDescriptor[]{ problemDescriptor }; }
Example 17
Source File: MarklogicExtendedSyntaxInspection.java From intellij-xquery with Apache License 2.0 | 4 votes |
private ProblemDescriptor createProblem(InspectionManager manager, PsiElement element) { return manager.createProblemDescriptor(element, "MarkLogic extended syntax used when version is not set to 'MarkLogic extended'.", (LocalQuickFix) null, ProblemHighlightType.GENERIC_ERROR, true); }