Package fr.adrienbrault.idea.symfony2plugin.util

Source Code of fr.adrienbrault.idea.symfony2plugin.util.CommandUtil

package fr.adrienbrault.idea.symfony2plugin.util;

import com.intellij.openapi.project.Project;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.php.PhpIndex;
import com.jetbrains.php.lang.psi.elements.Method;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import com.jetbrains.php.lang.psi.elements.PhpReturn;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

public class CommandUtil {

    public static Map<String, String> getCommandHelper(Project project) {

        Map<String, String> map = new HashMap<String, String>();
        Collection<PhpClass> phpClasses = PhpIndex.getInstance(project).getAllSubclasses("\\Symfony\\Component\\Console\\Helper\\HelperInterface");
        for(PhpClass phpClass: phpClasses) {
            Method method = PhpElementsUtil.getClassMethod(phpClass, "getName");
            for(PhpReturn phpReturn: PsiTreeUtil.findChildrenOfType(method, PhpReturn.class)) {
                String nameValue = PhpElementsUtil.getStringValue(phpReturn.getArgument());
                if(nameValue != null) {
                    String presentableFQN = phpClass.getPresentableFQN();
                    if(presentableFQN != null) {
                        map.put(nameValue, presentableFQN);
                    }
                }
            }
        }

        return map;
    }


}
TOP

Related Classes of fr.adrienbrault.idea.symfony2plugin.util.CommandUtil

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.