use of com.jetbrains.php.lang.psi.visitors.PhpElementVisitor in project idea-php-typo3-plugin by cedricziel.
the class FunctionCallMatcherInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
return new PhpElementVisitor() {
@Override
public void visitPhpElement(PhpPsiElement element) {
if (!PlatformPatterns.psiElement(PhpElementTypes.FUNCTION_CALL).accepts(element)) {
return;
}
Set<String> constants = getRemovedGlobalFuntions(element);
FunctionReference constantReference = (FunctionReference) element;
if (constants.contains(constantReference.getFQN())) {
problemsHolder.registerProblem(element, "Global function removed with TYPO3 9, consider using an alternative");
}
}
};
}
use of com.jetbrains.php.lang.psi.visitors.PhpElementVisitor in project idea-php-typo3-plugin by cedricziel.
the class MethodArgumentDroppedMatcherInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
return new PhpElementVisitor() {
@Override
public void visitPhpElement(PhpPsiElement element) {
if (!PlatformPatterns.psiElement(PhpElementTypes.METHOD_REFERENCE).accepts(element)) {
return;
}
MethodReference methodReference = (MethodReference) element;
ParameterList parameterList = methodReference.getParameterList();
PhpExpression classReference = methodReference.getClassReference();
if (classReference != null) {
PhpType inferredType = classReference.getInferredType();
String compiledClassMethodKey = inferredType.toString() + "->" + methodReference.getName();
if (ExtensionScannerUtil.classMethodHasDroppedArguments(element.getProject(), compiledClassMethodKey)) {
Integer maximumNumberOfArguments = ExtensionScannerUtil.getMaximumNumberOfArguments(element.getProject(), compiledClassMethodKey);
if (parameterList != null && maximumNumberOfArguments != -1 && parameterList.getParameters().length != maximumNumberOfArguments) {
problemsHolder.registerProblem(element, "Number of arguments changed with TYPO3 9, consider refactoring");
}
}
}
}
};
}
Aggregations