use of com.jetbrains.php.lang.psi.elements.PhpPsiElement 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.elements.PhpPsiElement 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");
}
}
}
}
};
}
use of com.jetbrains.php.lang.psi.elements.PhpPsiElement in project phpinspectionsea by kalessil.
the class OpenapiPsiSearchUtil method findResolutionOperator.
/*
finds '::' or '->' node in a method reference and returns it;
we are aware of getReferenceType method, but we need operator itself for QF-ing
*/
@Nullable
public static PsiElement findResolutionOperator(@Nullable MemberReference reference) {
if (reference != null) {
final PhpPsiElement start = reference.getFirstPsiChild();
if (start != null) {
final PsiElement end = reference instanceof FieldReference ? reference.getLastChild() : start.getNextPsiSibling();
if (end != null) {
PsiElement current = start.getNextSibling();
while (current != null && current != end) {
final IElementType nodeType = current.getNode().getElementType();
if (nodeType == PhpTokenTypes.ARROW || nodeType == PhpTokenTypes.SCOPE_RESOLUTION) {
return current;
}
current = current.getNextSibling();
}
}
}
}
return null;
}
Aggregations