Search in sources :

Example 1 with FieldReference

use of com.jetbrains.php.lang.psi.elements.FieldReference 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;
}
Also used : IElementType(com.intellij.psi.tree.IElementType) FieldReference(com.jetbrains.php.lang.psi.elements.FieldReference) PhpPsiElement(com.jetbrains.php.lang.psi.elements.PhpPsiElement) PsiElement(com.intellij.psi.PsiElement) PhpPsiElement(com.jetbrains.php.lang.psi.elements.PhpPsiElement) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

PsiElement (com.intellij.psi.PsiElement)1 IElementType (com.intellij.psi.tree.IElementType)1 FieldReference (com.jetbrains.php.lang.psi.elements.FieldReference)1 PhpPsiElement (com.jetbrains.php.lang.psi.elements.PhpPsiElement)1 Nullable (org.jetbrains.annotations.Nullable)1