use of org.qi4j.ide.plugin.idea.common.inspections.AbstractFix in project qi4j-sdk by Qi4j.
the class AbstractInjectionAnnotationDeclarationOnFieldInspection method checkField.
@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);
}
use of org.qi4j.ide.plugin.idea.common.inspections.AbstractFix in project qi4j-sdk by Qi4j.
the class StructureAnnotationDeclaredCorrectlyInspection method verifyAnnotationDeclaredCorrectly.
@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;
}
use of org.qi4j.ide.plugin.idea.common.inspections.AbstractFix 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