use of org.qi4j.ide.plugin.idea.injections.invocation.common.Qi4jInvocationAnnotationUtil.InvocationAnnotationDeclarationValidationResult in project qi4j-sdk by Qi4j.
the class InvocationAnnotationDeclaredCorrectlyInspection method verifyAnnotationDeclaredCorrectly.
@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 };
}
Aggregations