private void collectSelects( QueryBuilderScopeContext qb, MethodReference methodReference, String name) { if (!Arrays.asList("select", "addSelect").contains(name)) { return; } // $qb->select('foo') PsiElement psiElement = PsiElementUtils.getMethodParameterPsiElementAt(methodReference, 0); String literalValue = PhpElementsUtil.getStringValue(psiElement); if (literalValue != null) { qb.addSelect(literalValue); return; } // $qb->select(array('foo', 'bar', 'accessoryDetail')) if (psiElement instanceof ArrayCreationExpression) { for (PsiElement arrayValue : PsiElementUtils.getChildrenOfTypeAsList( psiElement, PlatformPatterns.psiElement(PhpElementTypes.ARRAY_VALUE))) { if (arrayValue.getChildren().length == 1) { String arrayValueString = PhpElementsUtil.getStringValue(arrayValue.getChildren()[0]); if (arrayValueString != null) { qb.addSelect(arrayValueString); } } } } }
private void collectSelectInForm( QueryBuilderScopeContext qb, MethodReference methodReference, String name) { // $qb->from('foo', 'select') if (!"from".equals(name)) { return; } PsiElement psiElement = PsiElementUtils.getMethodParameterPsiElementAt(methodReference, 1); String literalValue = PhpElementsUtil.getStringValue(psiElement); if (literalValue != null) { qb.addSelect(literalValue); } }