XPathFunctionCall (PsiFile psiFile, int offset) { PsiElement e = psiFile.findElementAt(offset); while (e != null) { final XPathFunctionCall call = PsiTreeUtil.getParentOfType(e, XPathFunctionCall.class); if (call == null) { break; } final ASTNode lparen = call.getNode().findChildByType(XPathTokenTypes.LPAREN); if (lparen != null && lparen.getTextRange().getStartOffset() < offset) { return call; } e = PsiTreeUtil.getParentOfType(e, XPathFunctionCall.class, true); } return null; }