use of com.intellij.codeInspection.ProblemDescriptor in project qi4j-sdk by Qi4j.
the class AbstractInjectionAnnotationDeclarationOnFieldAndConstructorInspection method checkMethod.
@Override
public final ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
PsiParameterList parameterList = method.getParameterList();
PsiParameter[] parameters = parameterList.getParameters();
if (method.isConstructor()) {
List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
for (PsiParameter parameter : parameters) {
PsiAnnotation annotation = getAnnotationToCheck(parameter);
if (annotation != null) {
ProblemDescriptor[] descriptors = verifyAnnotationDeclaredCorrectly(parameter, annotation, manager);
if (descriptors != null) {
problems.addAll(asList(descriptors));
}
}
}
return problems.toArray(new ProblemDescriptor[problems.size()]);
} else {
List<ProblemDescriptor> problems = new LinkedList<ProblemDescriptor>();
for (PsiParameter parameter : parameters) {
PsiAnnotation annotationToCheck = getAnnotationToCheck(parameter);
if (annotationToCheck != null) {
String message = getInjectionAnnotationValidDeclarationMessage();
AbstractFix removeAnnotationFix = createRemoveAnnotationFix(annotationToCheck);
ProblemDescriptor problemDescriptor = manager.createProblemDescriptor(annotationToCheck, message, removeAnnotationFix, GENERIC_ERROR_OR_WARNING);
problems.add(problemDescriptor);
}
}
return problems.toArray(new ProblemDescriptor[problems.size()]);
}
}
Aggregations