/** $this->vars['test'] $view->vars = array_replace($view->vars, array(...)); */ private static void getFormViewVarsAttachKeys( Set<String> stringSet, FieldReference fieldReference) { // $this->vars['test'] PsiElement context = fieldReference.getContext(); if (context instanceof ArrayAccessExpression) { ArrayIndex arrayIndex = PsiTreeUtil.findChildOfType(context, ArrayIndex.class); if (arrayIndex != null) { PsiElement psiElement = arrayIndex.getFirstChild(); if (psiElement instanceof StringLiteralExpression) { String contents = ((StringLiteralExpression) psiElement).getContents(); if (StringUtils.isNotBlank(contents)) { stringSet.add(contents); } } } } // array_replace($view->vars, array(...)) if (context instanceof ParameterList) { PsiElement functionReference = context.getContext(); if (functionReference instanceof FunctionReference && "array_replace".equals(((FunctionReference) functionReference).getName())) { PsiElement[] psiElements = ((ParameterList) context).getParameters(); if (psiElements.length > 1) { if (psiElements[1] instanceof ArrayCreationExpression) { stringSet.addAll( PhpElementsUtil.getArrayCreationKeys((ArrayCreationExpression) psiElements[1])); } } } } }
/** * Adds nodes to the specified parent node recurrsively. * * @param parent_node the parent node. * @param list the list of child node names. */ protected void addNode(DefaultMutableTreeNode parent_node, Vector list) { SortableArray array = null; if (mode == DATE_ORIENTED && parent_node.getLevel() <= 2) { array = new Array(list.size()); for (int i = 0; i < list.size(); i++) ((Array) array).set(i, Integer.parseInt((String) list.elementAt(i))); } else { array = new StringArray(list.size()); for (int i = 0; i < list.size(); i++) ((StringArray) array).set(i, (String) list.elementAt(i)); } ArrayIndex index = array.sortAscendant(); for (int i = 0; i < array.getArraySize(); i++) { String name = (String) list.elementAt(index.get(i)); // Converts 1...12 to January...December. if (mode == DATE_ORIENTED && parent_node.getLevel() == 1) { int month = Integer.parseInt(name); name = JulianDay.getFullSpellMonthString(month); } DefaultMutableTreeNode node = new DefaultMutableTreeNode(name); parent_node.add(node); } }