use of com.jetbrains.php.lang.psi.elements.PhpEmpty in project phpinspectionsea by kalessil.
the class AssertEmptyStrategy method apply.
public static boolean apply(@NotNull String methodName, @NotNull MethodReference reference, @NotNull ProblemsHolder holder) {
boolean result = false;
if (targetMapping.containsKey(methodName)) {
final PsiElement[] assertionArguments = reference.getParameters();
if (assertionArguments.length > 0 && assertionArguments[0] instanceof PhpEmpty) {
final PsiElement[] emptyArguments = ((PhpEmpty) assertionArguments[0]).getVariables();
if (emptyArguments.length == 1) {
/* generate QF arguments */
final String suggestedAssertion = targetMapping.get(methodName);
final String[] suggestedArguments = new String[assertionArguments.length];
suggestedArguments[0] = emptyArguments[0].getText();
if (assertionArguments.length > 1) {
suggestedArguments[1] = assertionArguments[1].getText();
}
/* register an issue */
holder.registerProblem(reference, String.format(MessagesPresentationUtil.prefixWithEa(messagePattern), suggestedAssertion), new PhpUnitAssertFixer(suggestedAssertion, suggestedArguments));
result = true;
}
}
}
return result;
}
Aggregations